def test_add_cluster_status(self): os.environ["DYNAMODB_TABLE_K8_CLUSTERS"] = self.table_name event = { 'queryStringParameters': { 'cluster_status': 'testing', 'cluster_name': 'test_cluster_name' } } cluster_status.set_cluster_status(event, {})
def test_list_clusters_per_multiple_environment(self): os.environ["DYNAMODB_TABLE_K8_CLUSTERS"] = self.table_name event = { 'queryStringParameters': { 'cluster_status': 'testing', 'environment': 'test', 'cluster_name': 'test_cluster_name' } } environments = ['dev', 'stage', 'prod'] for env in environments: event['queryStringParameters']['environment'] = env res = cluster_status.set_cluster_status(event, {}) self.assertEqual(200, res.get('statusCode')) res = cluster_status.set_cluster_environment(event, {}) self.assertEqual(200, res.get('statusCode')) for env in environments: event = {'queryStringParameters': {'environment': env}} status = cluster_status.clusters_per_environment(event, {}) self.assertEqual(200, status.get('statusCode'), status) self.assertEqual('["test_cluster_name"]', status.get('body')) event = {'queryStringParameters': {'environment': 'thisiswrong'}} status = cluster_status.clusters_per_environment(event, {}) self.assertEqual(200, status.get('statusCode'), status) self.assertEqual('[]', status.get('body'))
def test_get_cluster_status(self): os.environ["DYNAMODB_TABLE_K8_CLUSTERS"] = self.table_name event = { 'queryStringParameters': { 'cluster_status': 'testing', 'environment': 'test', 'cluster_name': 'test_cluster_name' } } res = cluster_status.set_cluster_status(event, {}) self.assertEqual(200, res.get('statusCode')) res = cluster_status.set_cluster_environment(event, {}) self.assertEqual(200, res.get('statusCode')) event = {'queryStringParameters': {'environment': 'test'}} status = cluster_status.cluster_status(event, {}) self.assertEqual(200, status.get('statusCode'), status) self.assertEqual('["test_cluster_name"]', status.get('body'))