@@ -614,9 +614,15 @@ def setUp(self):
614614 self .mixin = l3_attrs_db .ExtraAttributesMixin ()
615615 directory .add_plugin (plugin_constants .L3 , self .mixin )
616616 self .ctx = context .get_admin_context ()
617- self .router = l3_models .Router ()
618- with db_api .CONTEXT_WRITER .using (self .ctx ):
619- self .ctx .session .add (self .router )
617+ self .router = self ._new_router (self .ctx )
618+
619+ @staticmethod
620+ @db_api .CONTEXT_WRITER
621+ def _new_router (ctx ):
622+ router = l3_models .Router ()
623+ ctx .session .add (router )
624+ l3_attrs_db .ExtraAttributesMixin .add_extra_attr (ctx , router )
625+ return router
620626
621627 def _get_default_api_values (self ):
622628 return {k : v .get ('transform_from_db' , lambda x : x )(v ['default' ])
@@ -625,8 +631,7 @@ def _get_default_api_values(self):
625631 def test_set_extra_attr_key_bad (self ):
626632 with testtools .ExpectedException (RuntimeError ):
627633 with db_api .CONTEXT_WRITER .using (self .ctx ):
628- self .mixin .set_extra_attr_value (self .ctx , self .router ,
629- 'bad' , 'value' )
634+ self .mixin .set_extra_attr_value (self .router , 'bad' , 'value' )
630635
631636 def test__extend_extra_router_dict_defaults (self ):
632637 rdict = {}
@@ -635,9 +640,8 @@ def test__extend_extra_router_dict_defaults(self):
635640
636641 def test_set_attrs_and_extend (self ):
637642 with db_api .CONTEXT_WRITER .using (self .ctx ):
638- self .mixin .set_extra_attr_value (self .ctx , self .router ,
639- 'ha_vr_id' , 99 )
640- self .mixin .set_extra_attr_value (self .ctx , self .router ,
643+ self .mixin .set_extra_attr_value (self .router , 'ha_vr_id' , 99 )
644+ self .mixin .set_extra_attr_value (self .router ,
641645 'availability_zone_hints' ,
642646 ['x' , 'y' , 'z' ])
643647 expected = self ._get_default_api_values ()
@@ -647,7 +651,7 @@ def test_set_attrs_and_extend(self):
647651 self .mixin ._extend_extra_router_dict (rdict , self .router )
648652 self .assertEqual (expected , rdict )
649653
650- self .mixin .set_extra_attr_value (self .ctx , self . router ,
654+ self .mixin .set_extra_attr_value (self .router ,
651655 'availability_zone_hints' ,
652656 ['z' , 'y' , 'z' ])
653657 expected ['availability_zone_hints' ] = ['z' , 'y' , 'z' ]
0 commit comments