def test_envs_from_app(self, get_mock): get_mock.return_value = Mock(status_code=500) app = {"name": "appname", "envs": {"ELASTICSEARCH_HOST": "ble"}, "units": [{"ID": "id"}]} backend = get_backend(app, "token") self.assertIsInstance(backend, ElasticSearch)
def test_envs_from_api(self, get_mock): response_mock = Mock(status_code=200) response_mock.json.return_value = { "METRICS_BACKEND": "logstash", "METRICS_ELASTICSEARCH_HOST": "http://easearch.com", "METRICS_LOGSTASH_HOST": "logstash.com", } get_mock.return_value = response_mock app = {"name": "appname", "units": [{"ProcessName": "web"}]} backend = get_backend(app, "token") self.assertIsInstance(backend, ElasticSearch)
def test_without_metrics(self, get_mock): get_mock.return_value = Mock(status_code=404) app = {"name": "appname"} with self.assertRaises(MetricNotEnabled): get_backend(app, "token")
def test_envs_from_app(self): app = {"name": "appname", "envs": {"ELASTICSEARCH_HOST": "ble"}, "units": [{"ID": "id"}]} backend = get_backend(app, 'token') self.assertIsInstance(backend, ElasticSearch)