def test_init(self): client = EagleEyePlatformClient(self.root_endpoint) self.assertEqual(client.root_endpoint, self.root_endpoint) self.assertTrue(isinstance(client.chart, Chart)) self.assertTrue(isinstance(client.task, Task)) def use_invalid_root_endpoint(): EagleEyePlatformClient('') self.assertRaises(InvalidArgumentError, use_invalid_root_endpoint)
def test_delete(self, mocked_requests_delete): client = EagleEyePlatformClient(self.root_endpoint) def pass_invalid_id(): client.chart.delete(None) self.assertRaises(InvalidArgumentError, pass_invalid_id) client.chart.delete(self.chart_id) mocked_requests_delete.assert_called_with('{0}/charts/{1}'.format( self.root_endpoint, self.chart_id))
def test_create(self, mocked_requests_post): client = EagleEyePlatformClient(self.root_endpoint) def pass_invalid_data(): client.chart.create(None) self.assertRaises(InvalidArgumentError, pass_invalid_data) data = {'description': 'sample'} client.chart.create(data) mocked_requests_post.assert_called_with('{0}/charts'.format( self.root_endpoint), json=data)
def test_update(self, mocked_requests_post): client = EagleEyePlatformClient(self.root_endpoint) def pass_invalid_id(): client.chart.update(None, {}) self.assertRaises(InvalidArgumentError, pass_invalid_id) def pass_invalid_data(): client.chart.update(self.chart_id, None) self.assertRaises(InvalidArgumentError, pass_invalid_data) data = {'description': 'update'} client.chart.update(self.chart_id, data) mocked_requests_post.assert_called_with('{0}/charts/{1}'.format( self.root_endpoint, self.chart_id), json=data)
def use_invalid_root_endpoint(): EagleEyePlatformClient('')
def test_list(self, mocked_requests_get_many): client = EagleEyePlatformClient(self.root_endpoint) client.chart.list() mocked_requests_get_many.assert_called_with('{0}/charts'.format( self.root_endpoint))