def test_update(self): httpretty.register_uri(httpretty.GET, self.base_href + "/tenants/current", location=self.tenant_href, status=302) httpretty.register_uri(httpretty.GET, self.tenant_href, body=json.dumps(self.tenant_body), content_type="application/json") httpretty.register_uri(httpretty.GET, self.custom_href, body=json.dumps(self.dir_body), content_type="application/json") httpretty.register_uri(httpretty.POST, self.custom_href, body=json.dumps(self.custom_body), content_type="application/json") custom_data = CustomData(self.client, href=self.custom_href) custom_data['rank'] = 'Admiral' custom_data.save() self.assertEqual(HTTPretty.last_request.method, 'POST') self.assertEqual(HTTPretty.last_request.path, self.custom_path)
def test_update(self): httpretty.register_uri( httpretty.GET, self.base_href + "/tenants/current", location=self.tenant_href, status=302) httpretty.register_uri( httpretty.GET, self.tenant_href, body=json.dumps(self.tenant_body), content_type="application/json") httpretty.register_uri( httpretty.GET, self.custom_href, body=json.dumps(self.dir_body), content_type="application/json") httpretty.register_uri( httpretty.POST, self.custom_href, body=json.dumps(self.custom_body), content_type="application/json") custom_data = CustomData(self.client, href=self.custom_href) custom_data['rank'] = 'Admiral' custom_data.save() self.assertEqual(HTTPretty.last_request.method, 'POST') self.assertEqual(HTTPretty.last_request.path, self.custom_path)
def test_delete(self): httpretty.register_uri( httpretty.GET, self.base_href + "/tenants/current", location=self.tenant_href, status=302) httpretty.register_uri( httpretty.GET, self.tenant_href, body=json.dumps(self.tenant_body), content_type="application/json") httpretty.register_uri( httpretty.GET, self.custom_href, body=json.dumps(self.custom_body), content_type="application/json") httpretty.register_uri( httpretty.POST, self.custom_href, body=json.dumps({}), content_type="application/json") httpretty.register_uri( httpretty.DELETE, self.custom_href, body='', status=204) custom_data = CustomData(self.client, href=self.custom_href) custom_data.delete() self.assertEqual(HTTPretty.last_request.method, 'DELETE') self.assertEqual(HTTPretty.last_request.path, self.custom_path) httpretty.register_uri( httpretty.DELETE, self.custom_href + '/rank', body='', status=204) del custom_data['rank'] self.assertEqual(HTTPretty.last_request.method, 'GET') self.assertEqual(HTTPretty.last_request.path, self.custom_path) custom_data.save() self.assertEqual(HTTPretty.last_request.method, 'POST') self.assertEqual(HTTPretty.last_request.path, self.custom_path)
def test_delete(self): httpretty.register_uri(httpretty.GET, self.base_href + "/tenants/current", location=self.tenant_href, status=302) httpretty.register_uri(httpretty.GET, self.tenant_href, body=json.dumps(self.tenant_body), content_type="application/json") httpretty.register_uri(httpretty.GET, self.custom_href, body=json.dumps(self.custom_body), content_type="application/json") httpretty.register_uri(httpretty.POST, self.custom_href, body=json.dumps({}), content_type="application/json") httpretty.register_uri(httpretty.DELETE, self.custom_href, body='', status=204) custom_data = CustomData(self.client, href=self.custom_href) custom_data.delete() self.assertEqual(HTTPretty.last_request.method, 'DELETE') self.assertEqual(HTTPretty.last_request.path, self.custom_path) httpretty.register_uri(httpretty.DELETE, self.custom_href + '/rank', body='', status=204) del custom_data['rank'] self.assertEqual(HTTPretty.last_request.method, 'GET') self.assertEqual(HTTPretty.last_request.path, self.custom_path) custom_data.save() self.assertEqual(HTTPretty.last_request.method, 'POST') self.assertEqual(HTTPretty.last_request.path, self.custom_path)