From 0cc042fd0b32e4da78e5e99223aa7bec8514861d Mon Sep 17 00:00:00 2001 From: David Brown Date: Mon, 12 Jul 2021 16:30:54 -0700 Subject: [PATCH] Add Happy Message This adds a happy message at the root of the service. Signed-off-by: David Brown --- pacifica/notifications/rest.py | 8 ++++++++ tests/eventmatch_test.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/pacifica/notifications/rest.py b/pacifica/notifications/rest.py index a5981d5..63e30a5 100644 --- a/pacifica/notifications/rest.py +++ b/pacifica/notifications/rest.py @@ -203,4 +203,12 @@ class Root: exposed = True eventmatch = EventMatch() receive = ReceiveEvent() + + @staticmethod + @cherrypy.tools.json_out() + # pylint: disable=invalid-name + def GET(): + """Return happy message about functioning service.""" + return {'message': 'Pacifica Notifications Up and Running'} + # pylint: enable=invalid-name # pylint: enable=too-few-public-methods diff --git a/tests/eventmatch_test.py b/tests/eventmatch_test.py index 05b739b..0fbc83b 100644 --- a/tests/eventmatch_test.py +++ b/tests/eventmatch_test.py @@ -10,6 +10,15 @@ class EventMatchCPTest(NotificationsCPTest, helper.CPWebCase): """Test the EventMatch class.""" + @eventmatch_droptables + def test_happy(self): + """Test the create POST method in EventMatch.""" + resp = requests.get('{}/'.format(self.url)) + self.assertEqual(resp.status_code, 200) + self.assertTrue('Content-Type' in resp.headers) + self.assertEqual(resp.headers['Content-Type'], 'application/json') + self.assertTrue('message' in resp.json()) + @eventmatch_droptables def test_create(self): """Test the create POST method in EventMatch."""