@@ -228,3 +228,45 @@ def test_hybrid_seed_parent_to_child_with_ref_relationship_no_model(self):
228228 seeder = HybridSeeder (session )
229229 self .assertIsNone (seeder .seed (ins .HYBRID_SEED_PARENT_TO_CHILD_WITH_REF_RELATIONSHIP_NO_MODEL ))
230230 print (session .new , session .dirty )
231+
232+ class TestSeederCostumizedPrefix (unittest .TestCase ):
233+ def setUp (self ) -> None :
234+ self .engine = create_engine ('sqlite://' )
235+ self .Session = sessionmaker (bind = self .engine )
236+ Base .metadata .create_all (self .engine )
237+
238+ def test_seeder_parent_to_child (self ):
239+ import json
240+ custom_instance = json .dumps (ins .PARENT_TO_CHILD )
241+ custom_instance = custom_instance .replace ('!' , '@' )
242+ custom_instance = json .loads (custom_instance )
243+
244+ with self .Session () as session :
245+ seeder = Seeder (session , ref_prefix = '@' )
246+ seeder .seed (custom_instance )
247+ employee = seeder .instances [0 ]
248+ self .assertIsNotNone (employee .company )
249+
250+ def test_hybrid_seeder_parent_to_child_with_ref_column (self ):
251+ import json
252+ custom_instance = json .dumps (ins .HYBRID_SEED_PARENT_TO_CHILD_WITH_REF_COLUMN )
253+ custom_instance = custom_instance .replace ('!' , '@' )
254+ custom_instance = json .loads (custom_instance )
255+
256+ with self .Session () as session :
257+ seeder = HybridSeeder (session , ref_prefix = '@' )
258+ seeder .seed (custom_instance )
259+ employee = seeder .instances [1 ]
260+ self .assertIsNotNone (employee .company )
261+
262+ def test_hybrid_seeder_parent_to_child_with_ref_relationship (self ):
263+ import json
264+ custom_instance = json .dumps (ins .HYBRID_SEED_PARENT_TO_CHILD_WITH_REF_RELATIONSHIP )
265+ custom_instance = custom_instance .replace ('!' , '@' )
266+ custom_instance = json .loads (custom_instance )
267+
268+ with self .Session () as session :
269+ seeder = HybridSeeder (session , ref_prefix = '@' )
270+ seeder .seed (custom_instance )
271+ employee = seeder .instances [1 ]
272+ self .assertIsNotNone (employee .company )
0 commit comments