tests: Verify info logs while testing send_to_email_mirror command.

This commit tests if info logs are logging using assertLogs so that the
log do not spam the test output.
This commit is contained in:
Mohit Gupta 2020-07-20 03:05:06 +05:30 committed by Tim Abbott
parent c02e011be4
commit 4c561653b3
1 changed files with 15 additions and 3 deletions

View File

@ -357,7 +357,11 @@ class TestSendToEmailMirror(ZulipTestCase):
self.login_user(user_profile)
self.subscribe(user_profile, "Denmark")
with self.assertLogs('zerver.lib.email_mirror', level='INFO') as info_log:
call_command(self.COMMAND_NAME, f"--fixture={fixture_path}")
self.assertEqual(info_log.output, [
'INFO:zerver.lib.email_mirror:Successfully processed email to Denmark (zulip)'
])
message = most_recent_message(user_profile)
# last message should be equal to the body of the email in 1.txt
@ -369,7 +373,11 @@ class TestSendToEmailMirror(ZulipTestCase):
self.login_user(user_profile)
self.subscribe(user_profile, "Denmark")
with self.assertLogs('zerver.lib.email_mirror', level='INFO') as info_log:
call_command(self.COMMAND_NAME, f"--fixture={fixture_path}")
self.assertEqual(info_log.output, [
'INFO:zerver.lib.email_mirror:Successfully processed email to Denmark (zulip)'
])
message = most_recent_message(user_profile)
# last message should be equal to the body of the email in 1.json
@ -381,7 +389,11 @@ class TestSendToEmailMirror(ZulipTestCase):
self.login_user(user_profile)
self.subscribe(user_profile, "Denmark2")
with self.assertLogs('zerver.lib.email_mirror', level='INFO') as info_log:
call_command(self.COMMAND_NAME, f"--fixture={fixture_path}", "--stream=Denmark2")
self.assertEqual(info_log.output, [
'INFO:zerver.lib.email_mirror:Successfully processed email to Denmark2 (zulip)'
])
message = most_recent_message(user_profile)
# last message should be equal to the body of the email in 1.txt