Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Verify info logs while testing send_to_email_mirror command.

Mohit Gupta4c561653b307
diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.py
index ac3672ba26d..c5799783cac 100644
--- a/zerver/tests/test_management_commands.py
+++ b/zerver/tests/test_management_commands.py
@@ -357,7 +357,11 @@ class TestSendToEmailMirror(ZulipTestCase):
self.login_user(user_profile)
self.subscribe(user_profile, "Denmark")
- call_command(self.COMMAND_NAME, f"--fixture={fixture_path}")
+ 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")
- call_command(self.COMMAND_NAME, f"--fixture={fixture_path}")
+ 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")
- call_command(self.COMMAND_NAME, f"--fixture={fixture_path}", "--stream=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