class RestHandleTest(unittest.TestCase): def setUp(self): self.http_client = RestHandle(URL, RESOURCE, METHOD, headers=HEADERS) @unittest.skipIf(sys.version_info < ( 2, 7 ), 'https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises' ) def test_insufficient_args(self): with self.assertRaises(Exception): RestHandle(URL, RESOURCE, None) @mock.patch('zanataclient.zanatalib.rest.client.RestHandle._call_request') def test_get_response_content(self, mock_call_request): mock_call_request.return_value = response, content response_content = self.http_client.get_response_content() self.assertEqual(len(response_content), 2, 'both response and content') self.assertEqual(response_content[0]['status'], '200', 'http response status') self.assertEqual(response_content[0]['content-type'], 'application/json', 'valid response') self.assertTrue('id' in response_content[1], 'project id should be in content') self.assertTrue('name' in response_content[1], 'project name should be in content') self.assertTrue('links' in response_content[1], 'links should be in content') self.assertTrue('status' in response_content[1], 'project status should be in content')
class RestHandleTest(unittest.TestCase): def setUp(self): self.http_client = RestHandle( URL, RESOURCE, METHOD, headers=HEADERS ) @unittest.skipIf( sys.version_info < (2, 7), 'https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises' ) def test_insufficient_args(self): with self.assertRaises(Exception): RestHandle(URL, RESOURCE, None) @mock.patch('zanataclient.zanatalib.rest.client.RestHandle._call_request') def test_get_response_content(self, mock_call_request): mock_call_request.return_value = response, content response_content = self.http_client.get_response_content() self.assertEqual(len(response_content), 2, 'both response and content') self.assertEqual(response_content[0]['status'], '200', 'http response status') self.assertEqual(response_content[0]['content-type'], 'application/json', 'valid response') self.assertTrue('id' in response_content[1], 'project id should be in content') self.assertTrue('name' in response_content[1], 'project name should be in content') self.assertTrue('links' in response_content[1], 'links should be in content') self.assertTrue('status' in response_content[1], 'project status should be in content')
def test_insufficient_args(self): with self.assertRaises(Exception): RestHandle(URL, RESOURCE, None)
def setUp(self): self.http_client = RestHandle(URL, RESOURCE, METHOD, headers=HEADERS)
def setUp(self): self.http_client = RestHandle( URL, RESOURCE, METHOD, headers=HEADERS )