<s> import contextlib <EOL> import datetime <EOL> import gettext <EOL> import iso8601 <EOL> import mock <EOL> from oslo_versionedobjects import base as object_base <EOL> from oslo_versionedobjects import exception as object_exception <EOL> from oslo_versionedobjects import fixture as object_fixture <EOL> import six <EOL> from ironic . common import context <EOL> from ironic . objects import base <EOL> from ironic . objects import fields <EOL> from ironic . tests import base as test_base <EOL> gettext . install ( '<STR_LIT>' ) <EOL> @ base . IronicObjectRegistry . register <EOL> class MyObj ( base . IronicObject , object_base . VersionedObjectDictCompat ) : <EOL> VERSION = '<STR_LIT>' <EOL> fields = { '<STR_LIT:foo>' : fields . IntegerField ( ) , <EOL> '<STR_LIT:bar>' : fields . StringField ( ) , <EOL> '<STR_LIT>' : fields . StringField ( ) , <EOL> } <EOL> def obj_load_attr ( self , attrname ) : <EOL> setattr ( self , attrname , '<STR_LIT>' ) <EOL> @ object_base . remotable_classmethod <EOL> def query ( cls , context ) : <EOL> obj = cls ( context ) <EOL> obj . foo = <NUM_LIT:1> <EOL> obj . bar = '<STR_LIT:bar>' <EOL> obj . obj_reset_changes ( ) <EOL> return obj <EOL> @ object_base . remotable <EOL> def marco ( self , context = None ) : <EOL> return '<STR_LIT>' <EOL> @ object_base . remotable <EOL> def update_test ( self , context = None ) : <EOL> if context and context . tenant == '<STR_LIT>' : <EOL> self . bar = '<STR_LIT>' <EOL> else : <EOL> self . bar = '<STR_LIT>' <EOL> @ object_base . remotable <EOL> def save ( self , context = None ) : <EOL> self . obj_reset_changes ( ) <EOL> @ object_base . remotable <EOL> def refresh ( self , context = None ) : <EOL> self . foo = <NUM_LIT> <EOL> self . bar = '<STR_LIT>' <EOL> self . obj_reset_changes ( ) <EOL> @ object_base . remotable <EOL> def modify_save_modify ( self , context = None ) : <EOL> self . bar = '<STR_LIT>' <EOL> self . save ( ) <EOL> self . foo = <NUM_LIT> <EOL> class MyObj2 ( object ) : <EOL> @ classmethod <EOL> def obj_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> @ object_base . remotable_classmethod <EOL> def get ( cls , * args , ** kwargs ) : <EOL> pass <EOL> @ base . IronicObjectRegistry . register_if ( False ) <EOL> class TestSubclassedObject ( MyObj ) : <EOL> fields = { '<STR_LIT>' : fields . StringField ( ) } <EOL> class _LocalTest ( test_base . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( _LocalTest , self ) . setUp ( ) <EOL> base . IronicObject . indirection_api = None <EOL> @ contextlib . contextmanager <EOL> def things_temporarily_local ( ) : <EOL> _api = base . IronicObject . indirection_api <EOL> base . IronicObject . indirection_api = None <EOL> yield <EOL> base . IronicObject . indirection_api = _api <EOL> class _TestObject ( object ) : <EOL> def test_hydration_type_error ( self ) : <EOL> primitive = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:foo>' : '<STR_LIT:a>' } } <EOL> self . assertRaises ( ValueError , MyObj . obj_from_primitive , primitive ) <EOL> def test_hydration ( self ) : <EOL> primitive = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:foo>' : <NUM_LIT:1> } } <EOL> obj = MyObj . obj_from_primitive ( primitive ) <EOL> self . assertEqual ( <NUM_LIT:1> , obj . foo ) <EOL> def test_hydration_bad_ns ( self ) : <EOL> primitive = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:foo>' : <NUM_LIT:1> } } <EOL> self . assertRaises ( object_exception . UnsupportedObjectError , <EOL> MyObj . obj_from_primitive , primitive ) <EOL> def test_dehydration ( self ) : <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT:foo>' : <NUM_LIT:1> } } <EOL> obj = MyObj ( self . context ) <EOL> obj . foo = <NUM_LIT:1> <EOL> obj . obj_reset_changes ( ) <EOL> self . assertEqual ( expected , obj . obj_to_primitive ( ) ) <EOL> def test_get_updates ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> self . assertEqual ( { } , obj . obj_get_changes ( ) ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( { '<STR_LIT:foo>' : <NUM_LIT> } , obj . obj_get_changes ( ) ) <EOL> obj . bar = '<STR_LIT:test>' <EOL> self . assertEqual ( { '<STR_LIT:foo>' : <NUM_LIT> , '<STR_LIT:bar>' : '<STR_LIT:test>' } , obj . obj_get_changes ( ) ) <EOL> obj . obj_reset_changes ( ) <EOL> self . assertEqual ( { } , obj . obj_get_changes ( ) ) <EOL> def test_object_property ( self ) : <EOL> obj = MyObj ( self . context , foo = <NUM_LIT:1> ) <EOL> self . assertEqual ( <NUM_LIT:1> , obj . foo ) <EOL> def test_object_property_type_error ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> def fail ( ) : <EOL> obj . foo = '<STR_LIT:a>' <EOL> self . assertRaises ( ValueError , fail ) <EOL> def test_load ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> def test_load_in_base ( self ) : <EOL> @ base . IronicObjectRegistry . register_if ( False ) <EOL> class Foo ( base . IronicObject , object_base . VersionedObjectDictCompat ) : <EOL> fields = { '<STR_LIT>' : fields . IntegerField ( ) } <EOL> obj = Foo ( self . context ) <EOL> self . assertRaisesRegexp ( <EOL> NotImplementedError , "<STR_LIT>" , <EOL> getattr , obj , '<STR_LIT>' ) <EOL> def test_loaded_in_primitive ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> obj . foo = <NUM_LIT:1> <EOL> obj . obj_reset_changes ( ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT:bar>' ] , <EOL> '<STR_LIT>' : { '<STR_LIT:foo>' : <NUM_LIT:1> , <EOL> '<STR_LIT:bar>' : '<STR_LIT>' } } <EOL> self . assertEqual ( expected , obj . obj_to_primitive ( ) ) <EOL> def test_changes_in_primitive ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj . obj_what_changed ( ) ) <EOL> primitive = obj . obj_to_primitive ( ) <EOL> self . assertTrue ( '<STR_LIT>' in primitive ) <EOL> obj2 = MyObj . obj_from_primitive ( primitive ) <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj2 . obj_what_changed ( ) ) <EOL> obj2 . obj_reset_changes ( ) <EOL> self . assertEqual ( set ( ) , obj2 . obj_what_changed ( ) ) <EOL> def test_unknown_objtype ( self ) : <EOL> self . assertRaises ( object_exception . UnsupportedObjectError , <EOL> base . IronicObject . obj_class_from_name , '<STR_LIT:foo>' , '<STR_LIT:1.0>' ) <EOL> def test_with_alternate_context ( self ) : <EOL> ctxt1 = context . RequestContext ( '<STR_LIT:foo>' , '<STR_LIT:foo>' ) <EOL> ctxt2 = context . RequestContext ( '<STR_LIT:bar>' , tenant = '<STR_LIT>' ) <EOL> obj = MyObj . query ( ctxt1 ) <EOL> obj . update_test ( ctxt2 ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> def test_orphaned_object ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> obj . _context = None <EOL> self . assertRaises ( object_exception . OrphanedObjectError , <EOL> obj . update_test ) <EOL> def test_changed_1 ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj . obj_what_changed ( ) ) <EOL> obj . update_test ( self . context ) <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) , obj . obj_what_changed ( ) ) <EOL> self . assertEqual ( <NUM_LIT> , obj . foo ) <EOL> def test_changed_2 ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj . obj_what_changed ( ) ) <EOL> obj . save ( ) <EOL> self . assertEqual ( set ( [ ] ) , obj . obj_what_changed ( ) ) <EOL> self . assertEqual ( <NUM_LIT> , obj . foo ) <EOL> def test_changed_3 ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj . obj_what_changed ( ) ) <EOL> obj . refresh ( ) <EOL> self . assertEqual ( set ( [ ] ) , obj . obj_what_changed ( ) ) <EOL> self . assertEqual ( <NUM_LIT> , obj . foo ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> def test_changed_4 ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> obj . bar = '<STR_LIT>' <EOL> self . assertEqual ( set ( [ '<STR_LIT:bar>' ] ) , obj . obj_what_changed ( ) ) <EOL> obj . modify_save_modify ( self . context ) <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' ] ) , obj . obj_what_changed ( ) ) <EOL> self . assertEqual ( <NUM_LIT> , obj . foo ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> def test_static_result ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> self . assertEqual ( '<STR_LIT:bar>' , obj . bar ) <EOL> result = obj . marco ( ) <EOL> self . assertEqual ( '<STR_LIT>' , result ) <EOL> def test_updates ( self ) : <EOL> obj = MyObj . query ( self . context ) <EOL> self . assertEqual ( <NUM_LIT:1> , obj . foo ) <EOL> obj . update_test ( ) <EOL> self . assertEqual ( '<STR_LIT>' , obj . bar ) <EOL> def test_base_attributes ( self ) : <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = iso8601 . iso8601 . Utc ( ) ) <EOL> datatime = fields . DateTimeField ( ) <EOL> obj = MyObj ( self . context ) <EOL> obj . created_at = dt <EOL> obj . updated_at = dt <EOL> expected = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : <EOL> { '<STR_LIT>' : datatime . stringify ( dt ) , <EOL> '<STR_LIT>' : datatime . stringify ( dt ) , <EOL> } <EOL> } <EOL> actual = obj . obj_to_primitive ( ) <EOL> self . assertEqual ( sorted ( expected [ '<STR_LIT>' ] ) , <EOL> sorted ( actual [ '<STR_LIT>' ] ) ) <EOL> del expected [ '<STR_LIT>' ] , actual [ '<STR_LIT>' ] <EOL> self . assertEqual ( expected , actual ) <EOL> def test_contains ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> self . assertFalse ( '<STR_LIT:foo>' in obj ) <EOL> obj . foo = <NUM_LIT:1> <EOL> self . assertTrue ( '<STR_LIT:foo>' in obj ) <EOL> self . assertFalse ( '<STR_LIT>' in obj ) <EOL> def test_obj_attr_is_set ( self ) : <EOL> obj = MyObj ( self . context , foo = <NUM_LIT:1> ) <EOL> self . assertTrue ( obj . obj_attr_is_set ( '<STR_LIT:foo>' ) ) <EOL> self . assertFalse ( obj . obj_attr_is_set ( '<STR_LIT:bar>' ) ) <EOL> self . assertRaises ( AttributeError , obj . obj_attr_is_set , '<STR_LIT>' ) <EOL> def test_get ( self ) : <EOL> obj = MyObj ( self . context , foo = <NUM_LIT:1> ) <EOL> self . assertEqual ( obj . get ( '<STR_LIT:foo>' , <NUM_LIT:2> ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( obj . get ( '<STR_LIT:foo>' ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( obj . get ( '<STR_LIT:bar>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( obj . get ( '<STR_LIT:bar>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( obj . get ( '<STR_LIT:bar>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertRaises ( AttributeError , obj . get , '<STR_LIT>' ) <EOL> self . assertRaises ( AttributeError , obj . get , '<STR_LIT>' , <NUM_LIT:3> ) <EOL> def test_object_inheritance ( self ) : <EOL> base_fields = list ( base . IronicObject . fields ) <EOL> myobj_fields = [ '<STR_LIT:foo>' , '<STR_LIT:bar>' , '<STR_LIT>' ] + base_fields <EOL> myobj3_fields = [ '<STR_LIT>' ] <EOL> self . assertTrue ( issubclass ( TestSubclassedObject , MyObj ) ) <EOL> self . assertEqual ( len ( myobj_fields ) , len ( MyObj . fields ) ) <EOL> self . assertEqual ( set ( myobj_fields ) , set ( MyObj . fields . keys ( ) ) ) <EOL> self . assertEqual ( len ( myobj_fields ) + len ( myobj3_fields ) , <EOL> len ( TestSubclassedObject . fields ) ) <EOL> self . assertEqual ( set ( myobj_fields ) | set ( myobj3_fields ) , <EOL> set ( TestSubclassedObject . fields . keys ( ) ) ) <EOL> def test_get_changes ( self ) : <EOL> obj = MyObj ( self . context ) <EOL> self . assertEqual ( { } , obj . obj_get_changes ( ) ) <EOL> obj . foo = <NUM_LIT> <EOL> self . assertEqual ( { '<STR_LIT:foo>' : <NUM_LIT> } , obj . obj_get_changes ( ) ) <EOL> obj . bar = '<STR_LIT:test>' <EOL> self . assertEqual ( { '<STR_LIT:foo>' : <NUM_LIT> , '<STR_LIT:bar>' : '<STR_LIT:test>' } , obj . obj_get_changes ( ) ) <EOL> obj . obj_reset_changes ( ) <EOL> self . assertEqual ( { } , obj . obj_get_changes ( ) ) <EOL> def test_obj_fields ( self ) : <EOL> @ base . IronicObjectRegistry . register_if ( False ) <EOL> class TestObj ( base . IronicObject , <EOL> object_base . VersionedObjectDictCompat ) : <EOL> fields = { '<STR_LIT:foo>' : fields . IntegerField ( ) } <EOL> obj_extra_fields = [ '<STR_LIT:bar>' ] <EOL> @ property <EOL> def bar ( self ) : <EOL> return '<STR_LIT>' <EOL> obj = TestObj ( self . context ) <EOL> self . assertEqual ( set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) , <EOL> set ( obj . obj_fields ) ) <EOL> def test_refresh_object ( self ) : <EOL> @ base . IronicObjectRegistry . register_if ( False ) <EOL> class TestObj ( base . IronicObject , <EOL> object_base . VersionedObjectDictCompat ) : <EOL> fields = { '<STR_LIT:foo>' : fields . IntegerField ( ) , <EOL> '<STR_LIT:bar>' : fields . StringField ( ) } <EOL> obj = TestObj ( self . context ) <EOL> current_obj = TestObj ( self . context ) <EOL> obj . foo = <NUM_LIT:10> <EOL> obj . bar = '<STR_LIT>' <EOL> current_obj . foo = <NUM_LIT:2> <EOL> current_obj . bar = '<STR_LIT>' <EOL> obj . obj_refresh ( current_obj ) <EOL> self . assertEqual ( obj . foo , <NUM_LIT:2> ) <EOL> self . assertEqual ( obj . bar , '<STR_LIT>' ) <EOL> def test_obj_constructor ( self ) : <EOL> obj = MyObj ( self . context , foo = <NUM_LIT> , bar = '<STR_LIT:abc>' ) <EOL> self . assertEqual ( <NUM_LIT> , obj . foo ) <EOL> self . assertEqual ( '<STR_LIT:abc>' , obj . bar ) <EOL> self . assertEqual ( set ( [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) , obj . obj_what_changed ( ) ) <EOL> def test_assign_value_without_DictCompat ( self ) : <EOL> class TestObj ( base . IronicObject ) : <EOL> fields = { '<STR_LIT:foo>' : fields . IntegerField ( ) , <EOL> '<STR_LIT:bar>' : fields . StringField ( ) } <EOL> obj = TestObj ( self . context ) <EOL> obj . foo = <NUM_LIT:10> <EOL> err_message = '<STR_LIT>' <EOL> try : <EOL> obj [ '<STR_LIT:bar>' ] = '<STR_LIT:value>' <EOL> except TypeError as e : <EOL> err_message = six . text_type ( e ) <EOL> finally : <EOL> self . assertIn ( "<STR_LIT>" , <EOL> err_message ) <EOL> class TestObject ( _LocalTest , _TestObject ) : <EOL> pass <EOL> expected_object_fingerprints = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> class TestObjectVersions ( test_base . TestCase ) : <EOL> def test_object_version_check ( self ) : <EOL> classes = base . IronicObjectRegistry . obj_classes ( ) <EOL> checker = object_fixture . ObjectVersionChecker ( obj_classes = classes ) <EOL> expect , actual = checker . test_hashes ( expected_object_fingerprints ) <EOL> self . assertEqual ( expect , actual , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class TestObjectSerializer ( test_base . TestCase ) : <EOL> def test_object_serialization ( self ) : <EOL> ser = base . IronicObjectSerializer ( ) <EOL> obj = MyObj ( self . context ) <EOL> primitive = ser . serialize_entity ( self . context , obj ) <EOL> self . assertTrue ( '<STR_LIT>' in primitive ) <EOL> obj2 = ser . deserialize_entity ( self . context , primitive ) <EOL> self . assertIsInstance ( obj2 , MyObj ) <EOL> self . assertEqual ( self . context , obj2 . _context ) <EOL> def test_object_serialization_iterables ( self ) : <EOL> ser = base . IronicObjectSerializer ( ) <EOL> obj = MyObj ( self . context ) <EOL> for iterable in ( list , tuple , set ) : <EOL> thing = iterable ( [ obj ] ) <EOL> primitive = ser . serialize_entity ( self . context , thing ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( primitive ) ) <EOL> for item in primitive : <EOL> self . assertFalse ( isinstance ( item , base . IronicObject ) ) <EOL> thing2 = ser . deserialize_entity ( self . context , primitive ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( thing2 ) ) <EOL> for item in thing2 : <EOL> self . assertIsInstance ( item , MyObj ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def _test_deserialize_entity_newer ( self , obj_version , backported_to , <EOL> mock_indirection_api , <EOL> my_version = '<STR_LIT>' ) : <EOL> ser = base . IronicObjectSerializer ( ) <EOL> mock_indirection_api . object_backport_versions . return_value = '<STR_LIT>' <EOL> @ base . IronicObjectRegistry . register <EOL> class MyTestObj ( MyObj ) : <EOL> VERSION = my_version <EOL> obj = MyTestObj ( self . context ) <EOL> obj . VERSION = obj_version <EOL> primitive = obj . obj_to_primitive ( ) <EOL> result = ser . deserialize_entity ( self . context , primitive ) <EOL> if backported_to is None : <EOL> self . assertFalse ( <EOL> mock_indirection_api . object_backport_versions . called ) <EOL> else : <EOL> self . assertEqual ( '<STR_LIT>' , result ) <EOL> versions = object_base . obj_tree_get_versions ( '<STR_LIT>' ) <EOL> mock_indirection_api . object_backport_versions . assert_called_with ( <EOL> self . context , primitive , versions ) <EOL> def test_deserialize_entity_newer_version_backports ( self ) : <EOL> "<STR_LIT>" <EOL> self . _test_deserialize_entity_newer ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_deserialize_entity_same_revision_does_not_backport ( self ) : <EOL> "<STR_LIT>" <EOL> self . _test_deserialize_entity_newer ( '<STR_LIT>' , None ) <EOL> def test_deserialize_entity_newer_revision_does_not_backport_zero ( self ) : <EOL> "<STR_LIT>" <EOL> self . _test_deserialize_entity_newer ( '<STR_LIT>' , None ) <EOL> def test_deserialize_entity_newer_revision_does_not_backport ( self ) : <EOL> "<STR_LIT>" <EOL> self . _test_deserialize_entity_newer ( '<STR_LIT>' , None ) <EOL> def test_deserialize_entity_newer_version_passes_revision ( self ) : <EOL> "<STR_LIT>" <EOL> self . _test_deserialize_entity_newer ( '<STR_LIT>' , '<STR_LIT>' , my_version = '<STR_LIT>' ) <EOL> class TestRegistry ( test_base . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_hook_chooses_newer_properly ( self , mock_objects ) : <EOL> reg = base . IronicObjectRegistry ( ) <EOL> reg . registration_hook ( MyObj , <NUM_LIT:0> ) <EOL> class MyNewerObj ( object ) : <EOL> VERSION = '<STR_LIT>' <EOL> @ classmethod <EOL> def obj_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> self . assertEqual ( MyObj , mock_objects . MyObj ) <EOL> reg . registration_hook ( MyNewerObj , <NUM_LIT:0> ) <EOL> self . assertEqual ( MyNewerObj , mock_objects . MyObj ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_hook_keeps_newer_properly ( self , mock_objects ) : <EOL> reg = base . IronicObjectRegistry ( ) <EOL> reg . registration_hook ( MyObj , <NUM_LIT:0> ) <EOL> class MyOlderObj ( object ) : <EOL> VERSION = '<STR_LIT>' <EOL> @ classmethod <EOL> def obj_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> self . assertEqual ( MyObj , mock_objects . MyObj ) <EOL> reg . registration_hook ( MyOlderObj , <NUM_LIT:0> ) <EOL> self . assertEqual ( MyObj , mock_objects . MyObj ) </s>
