From d661839e32157781d35734fe05821eb32534e3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sat, 4 Aug 2018 19:07:40 +0300 Subject: [PATCH] Don't serialize POST payload to JSON, Django's TestClient will do that for us. --- hc/api/tests/test_create_check.py | 3 +-- hc/api/tests/test_update_check.py | 5 +---- hc/front/tests/test_add_telegram.py | 10 +++++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/hc/api/tests/test_create_check.py b/hc/api/tests/test_create_check.py index 451520c5..0bfb6245 100644 --- a/hc/api/tests/test_create_check.py +++ b/hc/api/tests/test_create_check.py @@ -8,8 +8,7 @@ class CreateCheckTestCase(BaseTestCase): URL = "/api/v1/checks/" def post(self, data, expected_error=None, expected_fragment=None): - r = self.client.post(self.URL, json.dumps(data), - content_type="application/json") + r = self.client.post(self.URL, data, content_type="application/json") if expected_error: self.assertEqual(r.status_code, 400) diff --git a/hc/api/tests/test_update_check.py b/hc/api/tests/test_update_check.py index 043c2de9..67629bc1 100644 --- a/hc/api/tests/test_update_check.py +++ b/hc/api/tests/test_update_check.py @@ -13,10 +13,7 @@ class UpdateCheckTestCase(BaseTestCase): def post(self, code, data): url = "/api/v1/checks/%s" % code - r = self.client.post(url, json.dumps(data), - content_type="application/json") - - return r + return self.client.post(url, data, content_type="application/json") def test_it_works(self): r = self.post(self.check.code, { diff --git a/hc/front/tests/test_add_telegram.py b/hc/front/tests/test_add_telegram.py index f410bc7f..aa1a02b7 100644 --- a/hc/front/tests/test_add_telegram.py +++ b/hc/front/tests/test_add_telegram.py @@ -46,7 +46,7 @@ class AddTelegramTestCase(BaseTestCase): "text": "/start" } } - r = self.client.post("/integrations/telegram/bot/", json.dumps(data), + r = self.client.post("/integrations/telegram/bot/", data, content_type="application/json") self.assertEqual(r.status_code, 200) @@ -57,17 +57,17 @@ class AddTelegramTestCase(BaseTestCase): samples = ["", "{}"] # text is missing - samples.append(json.dumps({ + samples.append({ "message": {"chat": {"id": 123, "type": "group"}} - })) + }) # bad chat type - samples.append(json.dumps({ + samples.append({ "message": { "chat": {"id": 123, "type": "invalid"}, "text": "/start" } - })) + }) for sample in samples: r = self.client.post("/integrations/telegram/bot/", sample,