From 7853e9d2de7bae3ae1c6004881a9e844ac9a8b9a Mon Sep 17 00:00:00 2001 From: Wyatt Hoodes Date: Wed, 31 Jul 2019 14:30:38 -1000 Subject: [PATCH] test_events: Fix broken test case. This test was broken due to using an empty `RealmAuditLog` table. We fix this by mocking the creation of an export, thus creating an entry, similar to what we do in our other tests. --- zerver/tests/test_events.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 258974602b..74818f6987 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -117,7 +117,8 @@ from zerver.lib.message import ( UnreadMessagesResult, ) from zerver.lib.test_helpers import POSTRequestMock, get_subscription, \ - get_test_image_file, stub_event_queue_user_events, queries_captured + get_test_image_file, stub_event_queue_user_events, queries_captured, \ + create_dummy_file from zerver.lib.test_classes import ( ZulipTestCase, ) @@ -2759,13 +2760,15 @@ class EventsRegisterTest(ZulipTestCase): self.assert_on_error(error) def test_realm_export_notify_admins(self) -> None: - # TODO: This test is completely busted because the - # RealmAuditLog table is empty in it, so it's testing an event - # containing an empty list. + # 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([ - ('id', check_string), + ('id', check_int), ('event_time', check_string), ('acting_user_id', check_int), ('extra_data', check_dict_only([