def test_create_database_should_returns_500_when_name_is_blank(self): request = RequestFactory().post("/", {"name": ""}) view = CreateDatabase() view._client = mocks.FakeEC2Client() response = view.post(request) self.assertEqual(500, response.status_code) self.assertEqual("App name is empty", response.content)
def test_create_database_should_returns_500_when_name_is_blank(self): request = RequestFactory().post("/", {"name": ""}) view = CreateDatabase() view._client = mocks.FakeEC2Client() response = view.post(request) self.assertEqual(500, response.status_code) self.assertEqual("Instance name is empty", response.content)
def test_create_database_should_returns_500_when_name_is_missing(self): request = RequestFactory().post("/", {}) view = CreateDatabase() view._client = mocks.FakeEC2Client() response = view.post(request) self.assertEqual(500, response.status_code) self.assertEqual("Instance name is missing", response.content)
def test_create_database_should_returns_500_when_name_is_missing(self): request = RequestFactory().post("/", {}) view = CreateDatabase() view._client = mocks.FakeEC2Client() response = view.post(request) self.assertEqual(500, response.status_code) self.assertEqual("App name is missing", response.content)
def test_create_database_should_call_run_from_client(self): try: cli = mocks.FakeEC2Client() request = RequestFactory().post("/", {"name": "bowl", "service_host": "127.0.0.1"}) view = CreateDatabase() view._client = cli response = view.post(request) time.sleep(0.5) self.assertEqual(201, response.status_code) self.assertIn("run instance bowl", cli.actions) finally: self.cursor.execute("DROP DATABASE IF EXISTS bowl")
def test_create_database_should_authorize_access_to_the_instance(self): try: cli = mocks.FakeEC2Client() t = start_creator(DatabaseManager, cli) data = {"name": "entre_nous", "service_host": "127.0.0.1"} request = RequestFactory().post("/", data) view = CreateDatabase() view._client = cli response = view.post(request) t.stop() self.assertEqual(201, response.status_code) self.assertIn("authorize instance entre_nous", cli.actions) finally: self.cursor.execute("DROP DATABASE IF EXISTS entre_nous")
def test_create_database_should_call_run_from_client(self): try: cli = mocks.FakeEC2Client() t = start_creator(DatabaseManager, cli) data = {"name": "bowl", "service_host": "127.0.0.1"} request = RequestFactory().post("/", data) view = CreateDatabase() view._client = cli response = view.post(request) t.stop() self.assertEqual(201, response.status_code) self.assertIn("run instance bowl", cli.actions) finally: self.cursor.execute("DROP DATABASE IF EXISTS bowl")
def test_create_database(self): try: request = RequestFactory().post("/", {"name": "ciclops"}) view = CreateDatabase() view._client = mocks.FakeEC2Client() response = view.post(request) self.assertEqual(201, response.status_code) self.assertEqual("ok", response.content) time.sleep(0.5) self.cursor.execute("select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME = 'ciclops'") row = self.cursor.fetchone() self.assertEqual("ciclops", row[0]) finally: db = DatabaseManager("ciclops") db.drop_database()
def test_create_database_ec2(self): try: client = mocks.FakeEC2Client() t = start_creator(DatabaseManager, client) request = RequestFactory().post("/", {"name": "ciclops"}) view = CreateDatabase() view._client = client response = view.post(request) self.assertEqual(201, response.status_code) self.assertEqual("", response.content) t.stop() sql = "select SCHEMA_NAME from information_schema.SCHEMATA " + \ "where SCHEMA_NAME = 'ciclops'" self.cursor.execute(sql) row = self.cursor.fetchone() self.assertEqual("ciclops", row[0]) finally: db = DatabaseManager("ciclops") db.drop_database()