@@ -254,103 +254,3 @@ async def test_create_with_entity_association(
254254 AssociationScopesEntitiesRow .id == association .id
255255 )
256256 )
257-
258- @pytest .mark .asyncio
259- async def test_create_order (
260- self ,
261- database_engine : ExtendedAsyncSAEngine ,
262- test_scope_id : ScopeId ,
263- test_object_id : ObjectId ,
264- ) -> None :
265- """Test that _create is called before create_entity"""
266- create_order : list [str ] = []
267-
268- class OrderTrackingEntityCreator (RBACEntityCreator ):
269- def scope_id (self ) -> ScopeId :
270- return test_scope_id
271-
272- def object_id (self ) -> ObjectId :
273- return test_object_id
274-
275- async def create_entity (self , db_session : SASession ) -> None :
276- create_order .append ("entity" )
277- await super ().create_entity (db_session )
278-
279- class OrderTrackingRBACCreator (RBACCreator [str ]):
280- async def _create (self , db_session : SASession ) -> str :
281- create_order .append ("main" )
282- return "test-value"
283-
284- entity_creator = OrderTrackingEntityCreator ()
285- rbac_creator = OrderTrackingRBACCreator (entity_creator )
286-
287- async with database_engine .begin_session () as db_sess :
288- await rbac_creator .create (db_sess )
289- await db_sess .flush ()
290-
291- # Verify order: _create should be called before create_entity
292- assert create_order == ["main" , "entity" ]
293-
294- # Cleanup
295- await db_sess .execute (
296- sa .delete (AssociationScopesEntitiesRow ).where (
297- AssociationScopesEntitiesRow .scope_type == test_scope_id .scope_type ,
298- AssociationScopesEntitiesRow .scope_id == test_scope_id .scope_id ,
299- )
300- )
301-
302-
303- class TestScopeIdAndObjectId :
304- """Test cases for ScopeId and ObjectId"""
305-
306- @pytest .mark .asyncio
307- async def test_scope_id_serialization (self ) -> None :
308- """Test ScopeId to_str and from_str methods"""
309- scope_id = ScopeId (
310- scope_type = ScopeType .DOMAIN ,
311- scope_id = "test-domain-123" ,
312- )
313-
314- serialized = scope_id .to_str ()
315- assert serialized == "domain:test-domain-123"
316-
317- deserialized = ScopeId .from_str (serialized )
318- assert deserialized .scope_type == scope_id .scope_type
319- assert deserialized .scope_id == scope_id .scope_id
320-
321- @pytest .mark .asyncio
322- async def test_object_id_serialization (self ) -> None :
323- """Test ObjectId to_str and from_str methods"""
324- object_id = ObjectId (
325- entity_type = EntityType .USER ,
326- entity_id = "user-456" ,
327- )
328-
329- serialized = object_id .to_str ()
330- assert serialized == "user:user-456"
331-
332- deserialized = ObjectId .from_str (serialized )
333- assert deserialized .entity_type == object_id .entity_type
334- assert deserialized .entity_id == object_id .entity_id
335-
336- @pytest .mark .asyncio
337- async def test_scope_id_all_types (self ) -> None :
338- """Test ScopeId with all scope types"""
339- for scope_type in ScopeType :
340- scope_id = ScopeId (scope_type = scope_type , scope_id = f"test-{ scope_type } " )
341- serialized = scope_id .to_str ()
342- deserialized = ScopeId .from_str (serialized )
343-
344- assert deserialized .scope_type == scope_type
345- assert deserialized .scope_id == f"test-{ scope_type } "
346-
347- @pytest .mark .asyncio
348- async def test_object_id_all_types (self ) -> None :
349- """Test ObjectId with all entity types"""
350- for entity_type in EntityType :
351- object_id = ObjectId (entity_type = entity_type , entity_id = f"test-{ entity_type } " )
352- serialized = object_id .to_str ()
353- deserialized = ObjectId .from_str (serialized )
354-
355- assert deserialized .entity_type == entity_type
356- assert deserialized .entity_id == f"test-{ entity_type } "
0 commit comments