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.
This commit is contained in:
Wyatt Hoodes 2019-07-31 14:30:38 -10:00 committed by Tim Abbott
parent f93efcb89c
commit 7853e9d2de
1 changed files with 8 additions and 5 deletions

View File

@ -117,7 +117,8 @@ from zerver.lib.message import (
UnreadMessagesResult, UnreadMessagesResult,
) )
from zerver.lib.test_helpers import POSTRequestMock, get_subscription, \ 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 ( from zerver.lib.test_classes import (
ZulipTestCase, ZulipTestCase,
) )
@ -2759,13 +2760,15 @@ class EventsRegisterTest(ZulipTestCase):
self.assert_on_error(error) self.assert_on_error(error)
def test_realm_export_notify_admins(self) -> None: def test_realm_export_notify_admins(self) -> None:
# TODO: This test is completely busted because the # Create the `realm_exported` RealmAuditLog object
# RealmAuditLog table is empty in it, so it's testing an event with mock.patch('zerver.lib.export.do_export_realm',
# containing an empty list. return_value=create_dummy_file('test-export.tar.gz')):
self.client_post('/json/export/realm')
schema_checker = self.check_events_dict([ schema_checker = self.check_events_dict([
('type', equals('realm_export')), ('type', equals('realm_export')),
('exports', check_list(check_dict_only([ ('exports', check_list(check_dict_only([
('id', check_string), ('id', check_int),
('event_time', check_string), ('event_time', check_string),
('acting_user_id', check_int), ('acting_user_id', check_int),
('extra_data', check_dict_only([ ('extra_data', check_dict_only([