3434)
3535
3636
37- # Generic doesn't need a more descriptive name
38- # pylint: disable=invalid-name
39- T = TypeVar ('T' , bound = ModelData )
40-
41-
42- def setupAsync (query_result : List [T ]) -> Tuple [AsyncModel [T ], AsyncClient ]:
37+ def setupAsync (
38+ query_result : List [ModelData ]
39+ ) -> Tuple [AsyncModel [ModelData ], AsyncClient ]:
4340 """Setup helper that returns instances of both a Model & a Client.
4441
4542 Mocks the execute_and_return method on the Client instance to skip
@@ -60,12 +57,14 @@ def setupAsync(query_result: List[T]) -> Tuple[AsyncModel[T], AsyncClient]:
6057 return_value = query_result )
6158
6259 # init a real model with mocked client
63- model = AsyncModel [Any ](client , 'test' )
60+ model = AsyncModel [Any ](client , 'test' , ModelData )
6461
6562 return model , client
6663
6764
68- def setupSync (query_result : List [T ]) -> Tuple [SyncModel [T ], SyncClient ]:
65+ def setupSync (
66+ query_result : List [ModelData ]
67+ ) -> Tuple [SyncModel [ModelData ], SyncClient ]:
6968 """Setup helper that returns instances of both a Model & a Client.
7069
7170 Mocks the execute_and_return method on the Client instance to skip
@@ -86,7 +85,7 @@ def setupSync(query_result: List[T]) -> Tuple[SyncModel[T], SyncClient]:
8685 return_value = query_result )
8786
8887 # init a real model with mocked client
89- model = SyncModel [Any ](client , 'test' )
88+ model = SyncModel [ModelData ](client , 'test' , ModelData )
9089
9190 return model , client
9291
@@ -100,8 +99,8 @@ async def test_it_correctly_builds_query_with_given_id(self) -> None:
10099 async_model , async_client = setupAsync ([item ])
101100 sync_model , sync_client = setupSync ([item ])
102101
103- await async_model .read .one_by_id (str ( item .id ) )
104- sync_model .read .one_by_id (str ( item .id ) )
102+ await async_model .read .one_by_id (item .id )
103+ sync_model .read .one_by_id (item .id )
105104
106105 async_query_composed = cast (
107106 helpers .AsyncMock , async_client .execute_and_return ).call_args [0 ][0 ]
@@ -124,8 +123,8 @@ async def test_it_returns_a_single_result(self) -> None:
124123 item = ModelData (id = uuid4 ())
125124 async_model , _ = setupAsync ([item ])
126125 sync_model , _ = setupSync ([item ])
127- results = [await async_model .read .one_by_id (str ( item .id ) ),
128- sync_model .read .one_by_id (str ( item .id ) )]
126+ results = [await async_model .read .one_by_id (item .id ),
127+ sync_model .read .one_by_id (item .id )]
129128
130129 for result in results :
131130 with self .subTest ():
@@ -139,11 +138,11 @@ async def test_it_raises_exception_if_more_than_one_result(self) -> None:
139138
140139 with self .subTest ():
141140 with self .assertRaises (UnexpectedMultipleResults ):
142- await async_model .read .one_by_id (str ( item .id ) )
141+ await async_model .read .one_by_id (item .id )
143142
144143 with self .subTest ():
145144 with self .assertRaises (UnexpectedMultipleResults ):
146- sync_model .read .one_by_id (str ( item .id ) )
145+ sync_model .read .one_by_id (item .id )
147146
148147 @ helpers .async_test
149148 async def test_it_raises_exception_if_no_result_to_return (self ) -> None :
@@ -265,8 +264,8 @@ async def test_it_returns_the_new_record(self) -> None:
265264 sync_model , _ = setupSync ([updated ])
266265
267266 results = [
268- await async_model .update .one_by_id (str ( item .id ) , {'b' : 'c' }),
269- sync_model .update .one_by_id (str ( item .id ) , {'b' : 'c' })
267+ await async_model .update .one_by_id (item .id , {'b' : 'c' }),
268+ sync_model .update .one_by_id (item .id , {'b' : 'c' })
270269 ]
271270
272271 for result in results :
0 commit comments