def test_pause_sets_reason(self): admin = self.factory.create_admin() rv = self.make_request( "post", "/api/data_sources/{}/pause".format(self.factory.data_source.id), user=admin, data={"reason": "testing"}, ) self.assertEqual(rv.status_code, 200) self.assertEqual(DataSource.get_by_id(self.factory.data_source.id).paused, True) self.assertEqual(DataSource.get_by_id(self.factory.data_source.id).pause_reason, "testing") rv = self.make_request( "post", "/api/data_sources/{}/pause?reason=test".format(self.factory.data_source.id), user=admin ) self.assertEqual(DataSource.get_by_id(self.factory.data_source.id).pause_reason, "test")
def test_resumes_data_source(self): admin = self.factory.create_admin() self.factory.data_source.pause() self.factory.data_source.save() rv = self.make_request("delete", "/api/data_sources/{}/pause".format(self.factory.data_source.id), user=admin) self.assertEqual(rv.status_code, 200) self.assertEqual(DataSource.get_by_id(self.factory.data_source.id).paused, False)
def test_pauses_data_source(self): admin = self.factory.create_admin() rv = self.make_request('post', '/api/data_sources/{}/pause'.format( self.factory.data_source.id), user=admin) self.assertEqual(rv.status_code, 200) self.assertEqual( DataSource.get_by_id(self.factory.data_source.id).paused, True)
def test_can_delete_group_with_data_sources(self): group = self.factory.create_group() data_source = self.factory.create_data_source(group=group) response = self.make_request('delete', '/api/groups/{}'.format(group.id), user=self.factory.create_admin()) self.assertEqual(response.status_code, 200) self.assertEqual(data_source, DataSource.get_by_id(data_source.id))
def test_resumes_data_source(self): admin = self.factory.create_admin() self.factory.data_source.pause() self.factory.data_source.save() rv = self.make_request('delete', '/api/data_sources/{}/pause'.format( self.factory.data_source.id), user=admin) self.assertEqual(rv.status_code, 200) self.assertEqual( DataSource.get_by_id(self.factory.data_source.id).paused, False)
def test_pause_sets_reason(self): admin = self.factory.create_admin() rv = self.make_request('post', '/api/data_sources/{}/pause'.format( self.factory.data_source.id), user=admin, data={'reason': 'testing'}) self.assertEqual(rv.status_code, 200) self.assertEqual( DataSource.get_by_id(self.factory.data_source.id).paused, True) self.assertEqual( DataSource.get_by_id(self.factory.data_source.id).pause_reason, 'testing') rv = self.make_request('post', '/api/data_sources/{}/pause?reason=test'.format( self.factory.data_source.id), user=admin) self.assertEqual( DataSource.get_by_id(self.factory.data_source.id).pause_reason, 'test')
def test_updates_data_source(self): admin = self.factory.create_admin() new_name = "New Name" new_options = {"dbname": "newdb"} rv = self.make_request( "post", self.path, data={"name": new_name, "type": "pg", "options": new_options}, user=admin ) self.assertEqual(rv.status_code, 200) data_source = DataSource.get_by_id(self.factory.data_source.id) self.assertEqual(data_source.name, new_name) self.assertEqual(data_source.options.to_dict(), new_options)
def test_updates_data_source(self): admin = self.factory.create_admin() new_name = 'New Name' new_options = {"dbname": "newdb"} rv = self.make_request('post', self.path, data={'name': new_name, 'type': 'pg', 'options': new_options}, user=admin) self.assertEqual(rv.status_code, 200) data_source = DataSource.get_by_id(self.factory.data_source.id) self.assertEqual(data_source.name, new_name) self.assertEqual(data_source.options.to_dict(), new_options)
def test_pauses_data_source(self): admin = self.factory.create_admin() rv = self.make_request("post", "/api/data_sources/{}/pause".format(self.factory.data_source.id), user=admin) self.assertEqual(rv.status_code, 200) self.assertEqual(DataSource.get_by_id(self.factory.data_source.id).paused, True)