def test_accepted(self, mock): '''Test for ACCEPTED with proper headers''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format('resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') headers = { 'location': 'https://test.com/test', 'x-ms-request-id': 'test-id-string', 'retry-after': '1' } self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}, status_code=httplib.ACCEPTED, headers=headers) res = Resource(name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) res.get(name=res_name) self.assertEqual(self.ctx.instance.runtime_properties.get('async_op'), headers)
def test_accepted(self, mock): '''Test for ACCEPTED with proper headers''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format( 'resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') headers = { 'location': 'https://test.com/test', 'x-ms-request-id': 'test-id-string', 'retry-after': '1' } self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}, status_code=httplib.ACCEPTED, headers=headers) res = Resource( name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) res.get(name=res_name) self.assertEqual( self.ctx.instance.runtime_properties.get('async_op'), headers)
def test_good_get(self, mock): '''Test for a successful get request''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format('resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}) res = Resource(name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) data = res.get(name=res_name) self.assertTrue(isinstance(data, dict))
def test_good_get(self, mock): '''Test for a successful get request''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format( 'resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}) res = Resource( name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) data = res.get(name=res_name) self.assertTrue(isinstance(data, dict))