diff --git a/lintipy.py b/lintipy.py index dd8e448..cef4d51 100644 --- a/lintipy.py +++ b/lintipy.py @@ -45,6 +45,8 @@ def __call__(self, event, context): self.event = event self.context = context self.hook = json.loads(self.event['Records'][0]['Sns']['Message']) + self.event_type = self.event['Records'][0]['Sns']['Subject'] + logger.info('Received %s event', self.event_type) logger.debug(self.hook) @classmethod diff --git a/tests/test_lintipy.py b/tests/test_lintipy.py index 1d159c3..5dc4bd9 100644 --- a/tests/test_lintipy.py +++ b/tests/test_lintipy.py @@ -32,6 +32,7 @@ def handler(self): notice['Records'][0]['Sns']['Subject'] = subject notice['Records'][0]['Sns']['Message'] = message hnd.event = notice + hnd.event_type = subject hnd.hook = json.loads(message) hnd._session = requests.Session() return hnd @@ -81,9 +82,12 @@ def test_call(self, handler, caplog): content_type='application/json', ) handler.download_code = lambda: '.' + handler.event_type = None with caplog.at_level(logging.INFO, logger='lintipy'): handler(handler.event, {}) assert "linter exited with status code 0 in " in caplog.text + assert "Received check_run event" in caplog.text + assert handler.event_type == 'check_run' handler.cmd = 'tests.exit1' with caplog.at_level(logging.INFO, logger='lintipy'):