test_realm_export: Use assertLogs in endpoint tests to verify info log.

This is to avoid spam in test-backend output.
This commit is contained in:
Mohit Gupta
2020-07-27 01:15:51 +05:30
committed by Tim Abbott
parent 3eda7586f3
commit 82646e27c2

View File

@@ -45,8 +45,10 @@ class RealmExportTest(ZulipTestCase):
# Test the export logic.
with patch('zerver.lib.export.do_export_realm',
return_value=tarball_path) as mock_export:
with self.settings(LOCAL_UPLOADS_DIR=None), stdout_suppressed():
with self.settings(LOCAL_UPLOADS_DIR=None), stdout_suppressed(), \
self.assertLogs(level='INFO') as info_logs:
result = self.client_post('/json/export/realm')
self.assertTrue('INFO:root:Completed data export for zulip in ' in info_logs.output[0])
self.assert_json_success(result)
self.assertFalse(os.path.exists(tarball_path))
args = mock_export.call_args_list[0][1]
@@ -104,8 +106,9 @@ class RealmExportTest(ZulipTestCase):
# Test the export logic.
with patch('zerver.lib.export.do_export_realm',
return_value=tarball_path) as mock_export:
with stdout_suppressed():
with stdout_suppressed(), self.assertLogs(level='INFO') as info_logs:
result = self.client_post('/json/export/realm')
self.assertTrue('INFO:root:Completed data export for zulip in ' in info_logs.output[0])
self.assert_json_success(result)
self.assertFalse(os.path.exists(tarball_path))
args = mock_export.call_args_list[0][1]