typing: Add assertions for report returned from notify_server_error.

We don't have a specific type for the reports returned from the error
logging handlers. The check is necessary as they are currently typed
as `Dict[str, object]` in `run_handler`.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-06-21 15:27:14 -04:00 committed by Tim Abbott
parent 8ba8177dc5
commit 428dfd2693
1 changed files with 7 additions and 0 deletions

View File

@ -125,6 +125,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
report = self.run_handler(record)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -141,6 +142,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
report = self.run_handler(record)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -162,6 +164,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
report = self.run_handler(record)
self.assertIn("host", report)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -180,6 +183,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
record.request.get_host = orig_get_host
self.assertIn("host", report)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -192,6 +196,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
record.request.method = "GET"
self.assertIn("host", report)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -222,6 +227,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
report = self.run_handler(record)
self.assertIn("host", report)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)
@ -233,6 +239,7 @@ class AdminNotifyHandlerTest(ZulipTestCase):
report = self.run_handler(record)
self.assertIn("host", report)
self.assertIn("user", report)
assert isinstance(report["user"], dict)
self.assertIn("user_email", report["user"])
self.assertIn("user_role", report["user"])
self.assertIn("message", report)