예제 #1
0
 def test_missing_required_params(self):
     r = Resource(mock.MagicMock())
     r._meta_data['required_load_parameters'] = set(['IMPOSSIBLE'])
     with pytest.raises(MissingRequiredReadParameter) as MRREIO:
         r.load(partition='Common', name='test_load')
     assert MRREIO.value.message ==\
         "Missing required params: set(['IMPOSSIBLE'])"
예제 #2
0
 def test_missing_required_params(self):
     r = Resource(mock.MagicMock())
     r._meta_data['required_refresh_parameters'] = set(['IMPOSSIBLE'])
     with pytest.raises(MissingRequiredReadParameter) as MRREIO:
         r.load(partition='Common', name='test_load')
     assert MRREIO.value.message ==\
         "Missing required params: set(['IMPOSSIBLE'])"
예제 #3
0
 def test_requests_params_collision(self):
     r = Resource(mock.MagicMock())
     with pytest.raises(RequestParamKwargCollision) as RPKCEIO:
         r.load(partition='Common', name='test_load',
                requests_params={'partition': 'ERROR'})
     assert RPKCEIO.value.message ==\
         "Requests Parameter 'partition' collides with a load parameter"\
         " of the same name."
예제 #4
0
 def test_requests_params_collision(self):
     r = Resource(mock.MagicMock())
     with pytest.raises(RequestParamKwargCollision) as RPKCEIO:
         r.load(partition='Common',
                name='test_load',
                requests_params={'partition': 'ERROR'})
     assert RPKCEIO.value.message ==\
         "Requests Parameter 'partition' collides with a load parameter"\
         " of the same name."
예제 #5
0
 def test_success(self):
     r = Resource(mock.MagicMock())
     r._meta_data['allowed_lazy_attributes'] = []
     mockuri = "https://localhost/mgmt/tm/ltm/nat/~Common~test_load"
     attrs = {'get.return_value':
              MockResponse({u"generation": 0, u"selfLink": mockuri})}
     mock_session = mock.MagicMock(**attrs)
     r._meta_data['bigip']._meta_data =\
         {'icr_session': mock_session,
          'hostname': 'TESTDOMAINNAME'}
     r.generation = 0
     r.load(partition='Common', name='test_load')
     r.raw
     assert r.selfLink == mockuri
예제 #6
0
 def test_success(self):
     r = Resource(mock.MagicMock())
     r._meta_data['allowed_lazy_attributes'] = []
     mockuri = "https://localhost/mgmt/tm/ltm/nat/~Common~test_load"
     attrs = {
         'get.return_value':
         MockResponse({
             u"generation": 0,
             u"selfLink": mockuri
         })
     }
     mock_session = mock.MagicMock(**attrs)
     r._meta_data['bigip']._meta_data =\
         {'icr_session': mock_session,
          'hostname': 'TESTDOMAINNAME'}
     r.generation = 0
     r.load(partition='Common', name='test_load')
     r.raw
     assert r.selfLink == mockuri