diff --git a/loginput/__init__.py b/loginput/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/loginput/index.py b/loginput/index.py index 98c75876..598c4af5 100644 --- a/loginput/index.py +++ b/loginput/index.py @@ -23,7 +23,7 @@ def status(): request.body.close() response.status = 200 response.content_type = "application/json" - response.body = json.dumps(dict(status='ok')) + response.body = json.dumps(dict(status='ok', service='loginput')) return response @route('/test') diff --git a/rest/__init__.py b/rest/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rest/index.py b/rest/index.py index 4f17ab32..1b379e7a 100644 --- a/rest/index.py +++ b/rest/index.py @@ -68,7 +68,7 @@ def status(): request.body.close() response.status = 200 response.content_type = "application/json" - response.body = json.dumps(dict(status='ok')) + response.body = json.dumps(dict(status='ok', service='restapi')) sendMessgeToPlugins(request, response, 'status') return response diff --git a/tests/alerts/alert_test_suite.py b/tests/alerts/alert_test_suite.py index 04a11d45..de990de2 100644 --- a/tests/alerts/alert_test_suite.py +++ b/tests/alerts/alert_test_suite.py @@ -20,7 +20,11 @@ import json class AlertTestSuite(UnitTestSuite): + def teardown(self): + os.chdir(self.orig_path) + def setup(self): + self.orig_path = os.getcwd() super(AlertTestSuite, self).setup() alerts_dir = os.path.join(os.path.dirname(__file__), "../../alerts/") diff --git a/tests/loginput/loginput_test_suite.py b/tests/loginput/loginput_test_suite.py index e616cd8e..9797935e 100644 --- a/tests/loginput/loginput_test_suite.py +++ b/tests/loginput/loginput_test_suite.py @@ -14,13 +14,12 @@ sample_config = DotDict() sample_config.configfile = os.path.join(os.path.dirname(__file__), '../../loginput/index.conf') OptionParser.parse_args = mock.Mock(return_value=(sample_config, {})) -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../loginput/")) -import index -reload(index) +sys.path.append(os.path.join(os.path.dirname(__file__), "../../")) class LoginputTestSuite(HTTPTestSuite): def setup(self): + from loginput import index self.application = index.application super(LoginputTestSuite, self).setup() diff --git a/tests/loginput/test_loginput_index.py b/tests/loginput/test_loginput_index.py index 423f1ee9..1e5273f8 100644 --- a/tests/loginput/test_loginput_index.py +++ b/tests/loginput/test_loginput_index.py @@ -7,6 +7,13 @@ class TestTestRoute(LoginputTestSuite): status_code = 200 body = '' + +class TestStatusRoute(LoginputTestSuite): + routes = ['/status', '/status/'] + + status_code = 200 + body = '{"status": "ok", "service": "loginput"}' + # Routes left need to have unit tests written for: # @route('/_bulk',method='POST') # @route('/_bulk/',method='POST') diff --git a/tests/rest/rest_test_suite.py b/tests/rest/rest_test_suite.py index 518ec66c..647a59c5 100644 --- a/tests/rest/rest_test_suite.py +++ b/tests/rest/rest_test_suite.py @@ -14,14 +14,12 @@ sample_config = DotDict() sample_config.configfile = os.path.join(os.path.dirname(__file__), '../../rest/index.conf') OptionParser.parse_args = mock.Mock(return_value=(sample_config, {})) - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../rest/")) -import index -reload(index) +sys.path.append(os.path.join(os.path.dirname(__file__), "../../")) class RestTestSuite(HTTPTestSuite): def setup(self): + from rest import index self.application = index.application super(RestTestSuite, self).setup() diff --git a/tests/rest/test_rest_index.py b/tests/rest/test_rest_index.py index 7d3afb2e..77818a9c 100644 --- a/tests/rest/test_rest_index.py +++ b/tests/rest/test_rest_index.py @@ -27,7 +27,7 @@ class TestStatusRoute(RestTestSuite): routes = ['/status', '/status/'] status_code = 200 - body = '{"status": "ok"}' + body = '{"status": "ok", "service": "restapi"}' class TestKibanaDashboardsRoute(RestTestSuite):