1- async def test_paginated_find_page_length (repository_class , model_class , sa_manager ):
2- repo = repository_class (sa_manager .get_bind ())
1+ async def test_paginated_find_page_length (
2+ repository_class , model_class , sa_bind , sync_async_wrapper
3+ ):
4+ repo = repository_class (bind = sa_bind , model_class = model_class )
35 model = model_class (
46 name = "Someone" ,
57 )
6- await repo .save (model )
8+ await sync_async_wrapper ( repo .save (model ) )
79 model2 = model_class (
810 name = "SomeoneElse" ,
911 )
10- await repo .save (model2 )
12+ await sync_async_wrapper ( repo .save (model2 ) )
1113 model3 = model_class (
1214 name = "StillSomeoneElse" ,
1315 )
14- await repo .save (model3 )
16+ await sync_async_wrapper ( repo .save (model3 ) )
1517
16- results = await repo .paginated_find (page = 1 , items_per_page = 2 )
18+ results = await sync_async_wrapper ( repo .paginated_find (page = 1 , items_per_page = 2 ) )
1719 assert len (results .items ) == 2
1820 assert results .items [0 ].name == "Someone"
1921 assert results .items [1 ].name == "SomeoneElse"
@@ -26,24 +28,24 @@ async def test_paginated_find_page_length(repository_class, model_class, sa_mana
2628
2729
2830async def test_paginated_find_max_page_length_is_respected (
29- repository_class , model_class , sa_manager
31+ repository_class , model_class , sa_bind , sync_async_wrapper
3032):
31- repo = repository_class (sa_manager . get_bind () )
33+ repo = repository_class (bind = sa_bind , model_class = model_class )
3234 repo ._max_query_limit = 2
3335 model = model_class (
3436 name = "Someone" ,
3537 )
36- await repo .save (model )
38+ await sync_async_wrapper ( repo .save (model ) )
3739 model2 = model_class (
3840 name = "SomeoneElse" ,
3941 )
40- await repo .save (model2 )
42+ await sync_async_wrapper ( repo .save (model2 ) )
4143 model3 = model_class (
4244 name = "StillSomeoneElse" ,
4345 )
44- await repo .save (model3 )
46+ await sync_async_wrapper ( repo .save (model3 ) )
4547
46- results = await repo .paginated_find (page = 1 , items_per_page = 50 )
48+ results = await sync_async_wrapper ( repo .paginated_find (page = 1 , items_per_page = 50 ) )
4749 assert len (results .items ) == 2
4850 assert results .items [0 ].name == "Someone"
4951 assert results .items [1 ].name == "SomeoneElse"
@@ -55,22 +57,24 @@ async def test_paginated_find_max_page_length_is_respected(
5557 assert results .page_info .has_previous_page is False
5658
5759
58- async def test_paginated_find_last_page (repository_class , model_class , sa_manager ):
59- repo = repository_class (sa_manager .get_bind ())
60+ async def test_paginated_find_last_page (
61+ repository_class , model_class , sa_bind , sync_async_wrapper
62+ ):
63+ repo = repository_class (bind = sa_bind , model_class = model_class )
6064 model = model_class (
6165 name = "Someone" ,
6266 )
63- await repo .save (model )
67+ await sync_async_wrapper ( repo .save (model ) )
6468 model2 = model_class (
6569 name = "SomeoneElse" ,
6670 )
67- await repo .save (model2 )
71+ await sync_async_wrapper ( repo .save (model2 ) )
6872 model3 = model_class (
6973 name = "StillSomeoneElse" ,
7074 )
71- await repo .save (model3 )
75+ await sync_async_wrapper ( repo .save (model3 ) )
7276
73- results = await repo .paginated_find (page = 2 , items_per_page = 2 )
77+ results = await sync_async_wrapper ( repo .paginated_find (page = 2 , items_per_page = 2 ) )
7478 assert len (results .items ) == 1
7579 assert results .items [0 ].name == "StillSomeoneElse"
7680 assert results .page_info .page == 2
@@ -82,23 +86,23 @@ async def test_paginated_find_last_page(repository_class, model_class, sa_manage
8286
8387
8488async def test_paginated_find_after_last_page (
85- repository_class , model_class , sa_manager
89+ repository_class , model_class , sa_bind , sync_async_wrapper
8690):
87- repo = repository_class (sa_manager . get_bind () )
91+ repo = repository_class (bind = sa_bind , model_class = model_class )
8892 model = model_class (
8993 name = "Someone" ,
9094 )
91- await repo .save (model )
95+ await sync_async_wrapper ( repo .save (model ) )
9296 model2 = model_class (
9397 name = "SomeoneElse" ,
9498 )
95- await repo .save (model2 )
99+ await sync_async_wrapper ( repo .save (model2 ) )
96100 model3 = model_class (
97101 name = "StillSomeoneElse" ,
98102 )
99- await repo .save (model3 )
103+ await sync_async_wrapper ( repo .save (model3 ) )
100104
101- results = await repo .paginated_find (page = 4 , items_per_page = 2 )
105+ results = await sync_async_wrapper ( repo .paginated_find (page = 4 , items_per_page = 2 ) )
102106 assert len (results .items ) == 0
103107 assert results .page_info .page == 0
104108 assert results .page_info .items_per_page == 2
@@ -108,24 +112,24 @@ async def test_paginated_find_after_last_page(
108112
109113
110114async def test_paginated_find_no_result_filters (
111- repository_class , model_class , sa_manager
115+ repository_class , model_class , sa_bind , sync_async_wrapper
112116):
113- repo = repository_class (sa_manager . get_bind () )
117+ repo = repository_class (bind = sa_bind , model_class = model_class )
114118 model = model_class (
115119 name = "Someone" ,
116120 )
117- await repo .save (model )
121+ await sync_async_wrapper ( repo .save (model ) )
118122 model2 = model_class (
119123 name = "SomeoneElse" ,
120124 )
121- await repo .save (model2 )
125+ await sync_async_wrapper ( repo .save (model2 ) )
122126 model3 = model_class (
123127 name = "StillSomeoneElse" ,
124128 )
125- await repo .save (model3 )
129+ await sync_async_wrapper ( repo .save (model3 ) )
126130
127- results = await repo . paginated_find (
128- page = 1 , items_per_page = 2 , search_params = {"name" : "Goofy" }
131+ results = await sync_async_wrapper (
132+ repo . paginated_find ( page = 1 , items_per_page = 2 , search_params = {"name" : "Goofy" })
129133 )
130134 assert len (results .items ) == 0
131135 assert results .page_info .page == 0
0 commit comments