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

@@ -29,12 +29,12 @@ class ZcommandTest(ZulipTestCase):
payload = dict(command="/night")
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("Changed to dark theme", result.json()["msg"])
response_dict = self.assert_json_success(result)
self.assertIn("Changed to dark theme", response_dict["msg"])
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("still in dark theme", result.json()["msg"])
response_dict = self.assert_json_success(result)
self.assertIn("still in dark theme", response_dict["msg"])
def test_day_zcommand(self) -> None:
self.login("hamlet")
@@ -44,12 +44,12 @@ class ZcommandTest(ZulipTestCase):
payload = dict(command="/day")
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("Changed to light theme", result.json()["msg"])
response_dict = self.assert_json_success(result)
self.assertIn("Changed to light theme", response_dict["msg"])
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("still in light theme", result.json()["msg"])
response_dict = self.assert_json_success(result)
self.assertIn("still in light theme", response_dict["msg"])
def test_fluid_zcommand(self) -> None:
self.login("hamlet")