@@ -275,3 +275,73 @@ async def test_async_fixture_and_query(async_engine: AsyncEngine, sqlquery_test_
275
275
)
276
276
assert not is_msgspec_struct_without_field (_msgspec_obj , "state_abbreviation" )
277
277
assert _get_one_or_none is None
278
+
279
+
280
+ @pytest .mark .xdist_group ("sqlquery" )
281
+ async def test_async_query_repository_instantiation (async_engine : AsyncEngine ) -> None :
282
+ """Test that SQLAlchemyAsyncQueryRepository can be instantiated without super().__init__() error."""
283
+ from advanced_alchemy .repository import SQLAlchemyAsyncQueryRepository
284
+
285
+ async with AsyncSession (async_engine ) as session :
286
+ # Test direct instantiation - this should not raise TypeError
287
+ repository = SQLAlchemyAsyncQueryRepository (session = session )
288
+ assert repository is not None
289
+ assert repository .session == session
290
+ assert repository .error_messages is None
291
+ assert repository .wrap_exceptions is True
292
+
293
+ # Test with optional parameters
294
+ repository_with_params = SQLAlchemyAsyncQueryRepository (
295
+ session = session , error_messages = {"not_found" : "Custom not found" }, wrap_exceptions = False
296
+ )
297
+ assert repository_with_params .session == session
298
+ assert repository_with_params .error_messages == {"not_found" : "Custom not found" }
299
+ assert repository_with_params .wrap_exceptions is False
300
+
301
+
302
+ @pytest .mark .xdist_group ("sqlquery" )
303
+ def test_sync_query_repository_instantiation (engine : Engine ) -> None :
304
+ """Test that SQLAlchemySyncQueryRepository can be instantiated without super().__init__() error."""
305
+ from advanced_alchemy .repository import SQLAlchemySyncQueryRepository
306
+
307
+ with Session (engine ) as session :
308
+ # Test direct instantiation - this should not raise TypeError
309
+ repository = SQLAlchemySyncQueryRepository (session = session )
310
+ assert repository is not None
311
+ assert repository .session == session
312
+ assert repository .error_messages is None
313
+ assert repository .wrap_exceptions is True
314
+
315
+ # Test with optional parameters
316
+ repository_with_params = SQLAlchemySyncQueryRepository (
317
+ session = session , error_messages = {"not_found" : "Custom not found" }, wrap_exceptions = False
318
+ )
319
+ assert repository_with_params .session == session
320
+ assert repository_with_params .error_messages == {"not_found" : "Custom not found" }
321
+ assert repository_with_params .wrap_exceptions is False
322
+
323
+
324
+ @pytest .mark .xdist_group ("sqlquery" )
325
+ async def test_async_query_service_with_repository_instantiation (async_engine : AsyncEngine ) -> None :
326
+ """Test that SQLAlchemyAsyncQueryService using the repository works correctly."""
327
+ from advanced_alchemy .service import SQLAlchemyAsyncQueryService
328
+
329
+ async with AsyncSession (async_engine ) as session :
330
+ # This should not raise TypeError when creating the repository internally
331
+ query_service = SQLAlchemyAsyncQueryService (session = session )
332
+ assert query_service is not None
333
+ assert query_service .repository is not None
334
+ assert query_service .repository .session == session
335
+
336
+
337
+ @pytest .mark .xdist_group ("sqlquery" )
338
+ def test_sync_query_service_with_repository_instantiation (engine : Engine ) -> None :
339
+ """Test that SQLAlchemySyncQueryService using the repository works correctly."""
340
+ from advanced_alchemy .service import SQLAlchemySyncQueryService
341
+
342
+ with Session (engine ) as session :
343
+ # This should not raise TypeError when creating the repository internally
344
+ query_service = SQLAlchemySyncQueryService (session = session )
345
+ assert query_service is not None
346
+ assert query_service .repository is not None
347
+ assert query_service .repository .session == session
0 commit comments