diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index d1c89a5137..1766bd3b02 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -94,7 +94,6 @@ from zerver.lib.actions import ( get_typing_user_profiles, log_event, lookup_default_stream_groups, - notify_realm_export, notify_realm_custom_profile_fields, check_add_user_group, do_update_user_group_name, @@ -2760,11 +2759,6 @@ class EventsRegisterTest(ZulipTestCase): self.assert_on_error(error) def test_notify_realm_export(self) -> None: - # Create the `realm_exported` RealmAuditLog object - with mock.patch('zerver.lib.export.do_export_realm', - return_value=create_dummy_file('test-export.tar.gz')): - self.client_post('/json/export/realm') - schema_checker = self.check_events_dict([ ('type', equals('realm_export')), ('exports', check_list(check_dict_only([ @@ -2778,13 +2772,17 @@ class EventsRegisterTest(ZulipTestCase): ]))) ]) - # Traditionally, we'd be testing the endpoint, but that - # requires somewhat annoying mocking setup for what to do with - # the export tarball. - events = self.do_test( - lambda: notify_realm_export(self.user_profile), - state_change_expected=False, num_events=1) - error = schema_checker('events[0]', events[0]) + do_change_is_admin(self.user_profile, True) + self.login(self.user_profile.email) + + with mock.patch('zerver.lib.export.do_export_realm', + return_value=create_dummy_file('test-export.tar.gz')): + events = self.do_test( + lambda: print(self.client_post('/json/export/realm').content), + state_change_expected=True, num_events=2) + + # The first event is a message from notification-bot. + error = schema_checker('events[1]', events[1]) self.assert_on_error(error) class FetchInitialStateDataTest(ZulipTestCase):