tests: Mock print() for management command tests.

This avoids spam in test-backend output.
This commit is contained in:
Mohit Gupta 2020-07-22 05:55:25 +05:30 committed by Tim Abbott
parent 9a10929a6c
commit a2a368df54
1 changed files with 5 additions and 1 deletions

View File

@ -407,7 +407,8 @@ class TestConvertMattermostData(ZulipTestCase):
COMMAND_NAME = 'convert_mattermost_data' COMMAND_NAME = 'convert_mattermost_data'
def test_if_command_calls_do_convert_data(self) -> None: def test_if_command_calls_do_convert_data(self) -> None:
with patch('zerver.management.commands.convert_mattermost_data.do_convert_data') as m: with patch('zerver.management.commands.convert_mattermost_data.do_convert_data') as m, \
patch('builtins.print') as mock_print:
mm_fixtures = self.fixture_file_name("", "mattermost_fixtures") mm_fixtures = self.fixture_file_name("", "mattermost_fixtures")
output_dir = self.make_import_output_dir("mattermost") output_dir = self.make_import_output_dir("mattermost")
call_command(self.COMMAND_NAME, mm_fixtures, f"--output={output_dir}") call_command(self.COMMAND_NAME, mm_fixtures, f"--output={output_dir}")
@ -417,6 +418,9 @@ class TestConvertMattermostData(ZulipTestCase):
mattermost_data_dir=os.path.realpath(mm_fixtures), mattermost_data_dir=os.path.realpath(mm_fixtures),
output_dir=os.path.realpath(output_dir), output_dir=os.path.realpath(output_dir),
) )
self.assertEqual(mock_print.mock_calls, [
call('Converting Data ...')
])
class TestInvoicePlans(ZulipTestCase): class TestInvoicePlans(ZulipTestCase):
COMMAND_NAME = 'invoice_plans' COMMAND_NAME = 'invoice_plans'