webhook tests: Avoid lots of unnecessary json dumping.

Commit c4254497b2
curiously had get_body() round tripping its data
through json load and dump.

I have seen this done for pretty-printing reasons,
but it doesn't apply here.

And if you're doing it for validation reasons,
you only need to do half the work, as my commit
here demonstrates.

We arguably don't even need the fail-fast code
here, since our fixtures are linted to be proper
json, I believe, plus downstream code probably
gives reasonably easy-to-diagnose symptoms.
This commit is contained in:
Steve Howell
2020-08-20 15:40:09 +00:00
committed by Tim Abbott
parent ef5de173fe
commit 95fe690e8d

View File

@@ -1152,7 +1152,10 @@ class WebhookTestCase(ZulipTestCase):
def get_body(self, fixture_name: str) -> str:
assert self.FIXTURE_DIR_NAME is not None
return orjson.dumps(orjson.loads(self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name))).decode()
body = self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name)
# fail fast if we don't have valid json
orjson.loads(body)
return body
class MigrationsTestCase(ZulipTestCase): # nocoverage
"""