logging: Migrate many backend tests to use assertLogs.

This commit  migrates some of the backend tests to use assertLogs(),
instead of mock.patch() as planned in #15331.

Tweaked by tabbott to avoid tautological assertions.
This commit is contained in:
m-e-l-u-h-a-n
2020-12-24 02:15:16 +05:30
committed by Tim Abbott
parent 7417ac9165
commit ccf520ff13
9 changed files with 133 additions and 176 deletions

View File

@@ -455,10 +455,9 @@ class HomeTest(ZulipTestCase):
def test_bad_narrow(self) -> None:
self.login('hamlet')
with patch('logging.warning') as mock:
with self.assertLogs(level='WARNING') as m:
result = self._get_home_page(stream='Invalid Stream')
mock.assert_called_once()
self.assertEqual(mock.call_args_list[0][0][0], "Invalid narrow requested, ignoring")
self.assertEqual(m.output, ['WARNING:root:Invalid narrow requested, ignoring'])
self._sanity_check(result)
def test_topic_narrow(self) -> None: