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'])"
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'])"
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."
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
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