mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	tests: Verify error logs while data export for zulip.
This commit verify that error logging while testing data export in test_notify_realm_export_on_failure using assertLogs so that the logs do not spam test output.
This commit is contained in:
		@@ -2418,12 +2418,18 @@ class NormalActionsTest(BaseAction):
 | 
			
		||||
        self.login_user(self.user_profile)
 | 
			
		||||
 | 
			
		||||
        with mock.patch('zerver.lib.export.do_export_realm',
 | 
			
		||||
                        side_effect=Exception("test")):
 | 
			
		||||
                        side_effect=Exception("test")), \
 | 
			
		||||
                self.assertLogs(level="ERROR") as error_log:
 | 
			
		||||
            with stdout_suppressed():
 | 
			
		||||
                events = self.verify_action(
 | 
			
		||||
                    lambda: self.client_post('/json/export/realm'),
 | 
			
		||||
                    state_change_expected=False, num_events=2)
 | 
			
		||||
 | 
			
		||||
            # Log is of following format: "ERROR:root:Data export for zulip failed after 0.004499673843383789"
 | 
			
		||||
            # Where last floating number is time and will vary in each test hence the following assertion is
 | 
			
		||||
            # independent of time bit by not matching exact log but only part of it.
 | 
			
		||||
            self.assertTrue("ERROR:root:Data export for zulip failed after" in error_log.output[0])
 | 
			
		||||
 | 
			
		||||
        pending_schema_checker('events[0]', events[0])
 | 
			
		||||
 | 
			
		||||
        failed_schema_checker('events[1]', events[1])
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user