From d11f5ac9170fd907b2a71b699cf8b714d36c6d66 Mon Sep 17 00:00:00 2001 From: JR Conlin Date: Thu, 7 May 2020 15:40:31 -0700 Subject: [PATCH] Bug/1388 (#1389) * bug: only use `failure()` on exceptions in write_error Closes #1388 --- autopush/base.py | 4 ++-- autopush/tests/test_web_base.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/autopush/base.py b/autopush/base.py index 574ef959..be2b72d8 100644 --- a/autopush/base.py +++ b/autopush/base.py @@ -65,8 +65,8 @@ def write_error(self, code, **kwargs): failure=failure.Failure(*kwargs['exc_info']), client_info=self._client_info) else: - self.log.failure("Error in handler: %s" % code, - client_info=self._client_info) + self.log.error("Error in handler: %s" % code, + client_info=self._client_info) self.finish() except Exception as ex: self.log.failure( diff --git a/autopush/tests/test_web_base.py b/autopush/tests/test_web_base.py index 1e08ee3e..25df401d 100644 --- a/autopush/tests/test_web_base.py +++ b/autopush/tests/test_web_base.py @@ -147,10 +147,13 @@ def test_write_error_no_exc(self): with an invalid method (e.g. "put" instead of "PUT"). This is not code that is triggered within normal flow, but by the cyclone wrapper. + + NOTE: calling `failure` without an exception triggers an + exception. write_error should call `error`. """ self.base.write_error(999) self.status_mock.assert_called_with(999) - assert self.base.log.failure.called is True + assert self.base.log.error.called is True @patch('uuid.uuid4', return_value=uuid.UUID(dummy_request_id)) def test_init_info(self, t):