Open wilian746 opened 5 years ago
Example how i use
def test_check_length_is_two(self):
self.session_unified = UnifiedAlchemyMagicMock()
self.session_unified.add(PermissionModel(
id="7de42c1b-7321-4042-84af-d9be3b3562f3",
description="permission of xablau"
))
self.session_unified.add(UserModel(
id="19dc9999-9331-4212-9199-e8f2acdcbb3f",
active=True,
name="xablau1",
email="xablau1@123.com",
password="@Xablau1",
permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
))
self.session_unified.add(UserModel(
id="29dc9999-9331-4212-9199-e8f2acdcbb3f",
active=True,
name="xablau2",
email="xablau2@123.com",
password="@Xablau2",
permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
))
self.session_unified.add(UserModel(
id="39dc9999-9331-4212-9199-e8f2acdcbb3f",
active=True,
name="xablau3",
email="xablau3@123.com",
password="@Xablau3",
permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
))
data = self.session_unified.query(UserModel).paginate(page=1, per_page=2, max_per_page=100)
# Broken because return an Empty List
self.assertEqual(len(data), 2)
@miki725, there's no paginate
method on sqlalchemy's query, its only available on flask-sqlalchemy's query implementation.
I use a method to paginate my queries but in the library I don't have this implementation whenever I use
session.query(Model).paginate(page=1, per_page=10, max_per_page=100)
returns an empty list. If this method is implemented I do not know how it should be applied!In sqlalchemy we have here how the implementation is usually done in the library https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#flask_sqlalchemy.Pagination