def test_drop(self): self.create_ciclops() request = RequestFactory().delete("/ciclops") self.fake = mocks.FakeEC2Client() view = DropDatabase() view._client = self.fake response = view.delete(request, "ciclops") self.assertEqual(200, response.status_code) with self.assertRaises(Instance.DoesNotExist): Instance.objects.get(name="ciclops")
def test_drop(self): self.create_ciclops() request = RequestFactory().delete("/ciclops") self.fake = mocks.FakeEC2Client() view = DropDatabase() view._client = self.fake response = view.delete(request, "ciclops") self.assertEqual(200, response.status_code) with self.assertRaises(Instance.DoesNotExist): Instance.objects.get(name="ciclops")
def test_should_remove_ec2_instance(self): self.create_ciclops() self.fake = mocks.FakeEC2Client() view = DropDatabase() view._client = self.fake request = RequestFactory().delete("/ciclops", {"service_host": "127.0.0.1"}) resp = view.delete(request, "ciclops") self.assertEqual(200, resp.status_code) self.assertEqual(["terminate instance ciclops"], self.fake.actions)
def test_should_unauthorize_ec2_instance_before_terminate_it(self): self.create_ciclops() fake = mocks.FakeEC2Client() view = DropDatabase() view._client = fake request = RequestFactory().delete("/ciclops") resp = view.delete(request, "ciclops") self.assertEqual(200, resp.status_code) actions = [u"unauthorize instance ciclops", u"terminate instance ciclops"] self.assertEqual(actions, fake.actions)
def test_should_unauthorize_ec2_instance_before_terminate_it(self): self.create_ciclops() fake = mocks.FakeEC2Client() view = DropDatabase() view._client = fake request = RequestFactory().delete("/ciclops") resp = view.delete(request, "ciclops") self.assertEqual(200, resp.status_code) actions = [u"unauthorize instance ciclops", u"terminate instance ciclops"] self.assertEqual(actions, fake.actions)
def test_drop_from_a_custom_service_host(self): self.create_ciclops() request = RequestFactory().delete("/ciclops", {"service_host": "127.0.0.1"}) self.fake = mocks.FakeEC2Client() view = DropDatabase() view._client = self.fake response = view.delete(request, "ciclops") self.assertEqual(200, response.status_code) self.cursor.execute("select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME = 'ciclops'") row = self.cursor.fetchone() self.assertFalse(row)
def test_drop(self): self.create_ciclops() request = RequestFactory().delete("/ciclops") self.fake = mocks.FakeEC2Client() view = DropDatabase() view._client = self.fake response = view.delete(request, "ciclops") self.assertEqual(200, response.status_code) self.cursor.execute("select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME = 'ciclops'") row = self.cursor.fetchone() self.assertFalse(row) with self.assertRaises(Instance.DoesNotExist): Instance.objects.get(name="ciclops")