@@ -246,6 +246,7 @@ def test__meta_data_state(self):
246246 pre_meta = r ._meta_data .copy ()
247247 r .update (a = u"b" )
248248 assert pre_meta == r ._meta_data
249+ assert r .raw == r .__dict__
249250
250251 def test_Collection_removal (self ):
251252 r = Resource (mock .MagicMock ())
@@ -539,6 +540,34 @@ def test_success(self):
539540 x = r .load (partition = 'Common' , name = 'test_load' )
540541 assert x .selfLink == mockuri
541542
543+ def test_URICreationCollision (self ):
544+ r = Virtual (mock .MagicMock ())
545+ r ._meta_data ['allowed_lazy_attributes' ] = []
546+ mockuri = "https://localhost:443/mgmt/tm/ltm/virtual/~Common~test_load"
547+ attrs = {'get.return_value' :
548+ MockResponse (
549+ {
550+ u"generation" : 0 ,
551+ u"selfLink" : mockuri ,
552+ u"kind" : u"tm:ltm:virtual:virtualstate"
553+ }
554+ )}
555+ mock_session = mock .MagicMock (** attrs )
556+ r ._meta_data ['bigip' ]._meta_data = \
557+ {'icr_session' : mock_session ,
558+ 'hostname' : 'TESTDOMAINNAME' ,
559+ 'uri' : 'https://TESTDOMAIN:443/mgmt/tm/' }
560+ r .generation = 0
561+ x = r .load (partition = 'Common' , name = 'test_load' )
562+ assert x .selfLink == mockuri
563+ with pytest .raises (URICreationCollision ) as UCCEIO :
564+ x .load (uri = 'URI' )
565+ assert UCCEIO .value .message == \
566+ "There was an attempt to assign a new uri to this resource, the" \
567+ " _meta_data['uri'] is " \
568+ "https://TESTDOMAIN:443/mgmt/tm/ltm/virtual/" \
569+ "~Common~test_load/ and it should not be changed."
570+
542571
543572class TestResource_exists (object ):
544573 def test_loadable (self ):
0 commit comments