class ServiceTest(unittest.TestCase): def setUp(self): self.service = Service(base_url="http://localhost", username='******', apikey='key', http_headers=None) def test_messages_status_200(self): result_set = self.service.messages(SERVICE_RESPONSE_200, RESPONSE_CONTENT_200) self.assertEqual(result_set[0]['project-id'], "12345") self.assertEqual(result_set[0]['project-name'], "test-project") def test_messages_status_200_xml(self): result_set = self.service.messages(SERVICE_RESPONSE_200_XML, RESPONSE_CONTENT_200_XML) self.assertEqual(result_set['project-version'], "12345") self.assertEqual(result_set['project'], "test-project") self.assertEqual(result_set['project-type'], "podir") def test_messages_status_201(self): result_set = self.service.messages(SERVICE_RESPONSE_201, RESPONSE_CONTENT) self.assertTrue(result_set) @unittest.skipIf(sys.version_info < ( 2, 7 ), 'https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises' ) def test_messages_status_401_503(self): with self.assertRaises(SystemExit): self.service.messages(SERVICE_RESPONSE_401, RESPONSE_CONTENT) with self.assertRaises(SystemExit) as ex: self.service.messages(SERVICE_RESPONSE_503, RESPONSE_CONTENT) self.assertEqual(ex.exception.code, 1)
class ServiceTest(unittest.TestCase): def setUp(self): self.service = Service(base_url="http://localhost", username='******', apikey='key', http_headers=None) def test_messages_status_200(self): result_set = self.service.messages(SERVICE_RESPONSE_200, RESPONSE_CONTENT_200) self.assertEqual(result_set[0]['project-id'], "12345") self.assertEqual(result_set[0]['project-name'], "test-project") def test_messages_status_200_xml(self): result_set = self.service.messages(SERVICE_RESPONSE_200_XML, RESPONSE_CONTENT_200_XML) self.assertEqual(result_set['project-version'], "12345") self.assertEqual(result_set['project'], "test-project") self.assertEqual(result_set['project-type'], "podir") def test_messages_status_201(self): result_set = self.service.messages(SERVICE_RESPONSE_201, RESPONSE_CONTENT) self.assertTrue(result_set) @unittest.skipIf( sys.version_info < (2, 7), 'https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises' ) def test_messages_status_401_503(self): with self.assertRaises(SystemExit): self.service.messages(SERVICE_RESPONSE_401, RESPONSE_CONTENT) with self.assertRaises(SystemExit) as ex: self.service.messages(SERVICE_RESPONSE_503, RESPONSE_CONTENT) self.assertEqual(ex.exception.code, 1)
class ServiceTest(unittest.TestCase): def setUp(self): self.service = Service(base_url="http://localhost", username='******', apikey='key', http_headers=None) def test_messages_status_200(self): result_set = self.service.messages(SERVICE_RESPONSE_200, RESPONSE_CONTENT_200) self.assertEqual(result_set[0]['project-id'], "12345") self.assertEqual(result_set[0]['project-name'], "test-project") def test_messages_status_201(self): result_set = self.service.messages(SERVICE_RESPONSE_201, RESPONSE_CONTENT) self.assertTrue(result_set) def test_messages_status_401_503(self): with self.assertRaises(SystemExit): self.service.messages(SERVICE_RESPONSE_401, RESPONSE_CONTENT) with self.assertRaises(SystemExit) as ex: self.service.messages(SERVICE_RESPONSE_503, RESPONSE_CONTENT) self.assertEqual(ex.exception.code, 1)
def setUp(self): self.service = Service(base_url="http://localhost", username='******', apikey='key', http_headers=None)
def setUp(self): self.service = Service(base_url="http://localhost", username='******', apikey='key', http_headers=None)