tests: Refactor away result.json() calls with helpers.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-06-06 19:37:01 -04:00
committed by Tim Abbott
parent a6e2453323
commit a142fbff85
33 changed files with 345 additions and 419 deletions

View File

@@ -74,10 +74,10 @@ class RealmExportTest(ZulipTestCase):
self.assertEqual(bucket.Object(path_id).get()["Body"].read(), b"zulip!")
result = self.client_get("/json/export/realm")
self.assert_json_success(result)
response_dict = self.assert_json_success(result)
# Test that the export we have is the export we created.
export_dict = result.json()["exports"]
export_dict = response_dict["exports"]
self.assertEqual(export_dict[0]["id"], audit_log_entry.id)
self.assertEqual(
export_dict[0]["export_url"],
@@ -144,10 +144,10 @@ class RealmExportTest(ZulipTestCase):
self.assert_streaming_content(response, b"zulip!")
result = self.client_get("/json/export/realm")
self.assert_json_success(result)
response_dict = self.assert_json_success(result)
# Test that the export we have is the export we created.
export_dict = result.json()["exports"]
export_dict = response_dict["exports"]
self.assertEqual(export_dict[0]["id"], audit_log_entry.id)
self.assertEqual(export_dict[0]["export_url"], admin.realm.uri + export_path)
self.assertEqual(export_dict[0]["acting_user_id"], admin.id)