forked from GithubBackups/healthchecks
Don't serialize POST payload to JSON, Django's TestClient will do that for us.
This commit is contained in:
parent
ccf8aa55f0
commit
d661839e32
@ -8,8 +8,7 @@ class CreateCheckTestCase(BaseTestCase):
|
|||||||
URL = "/api/v1/checks/"
|
URL = "/api/v1/checks/"
|
||||||
|
|
||||||
def post(self, data, expected_error=None, expected_fragment=None):
|
def post(self, data, expected_error=None, expected_fragment=None):
|
||||||
r = self.client.post(self.URL, json.dumps(data),
|
r = self.client.post(self.URL, data, content_type="application/json")
|
||||||
content_type="application/json")
|
|
||||||
|
|
||||||
if expected_error:
|
if expected_error:
|
||||||
self.assertEqual(r.status_code, 400)
|
self.assertEqual(r.status_code, 400)
|
||||||
|
@ -13,10 +13,7 @@ class UpdateCheckTestCase(BaseTestCase):
|
|||||||
|
|
||||||
def post(self, code, data):
|
def post(self, code, data):
|
||||||
url = "/api/v1/checks/%s" % code
|
url = "/api/v1/checks/%s" % code
|
||||||
r = self.client.post(url, json.dumps(data),
|
return self.client.post(url, data, content_type="application/json")
|
||||||
content_type="application/json")
|
|
||||||
|
|
||||||
return r
|
|
||||||
|
|
||||||
def test_it_works(self):
|
def test_it_works(self):
|
||||||
r = self.post(self.check.code, {
|
r = self.post(self.check.code, {
|
||||||
|
@ -46,7 +46,7 @@ class AddTelegramTestCase(BaseTestCase):
|
|||||||
"text": "/start"
|
"text": "/start"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r = self.client.post("/integrations/telegram/bot/", json.dumps(data),
|
r = self.client.post("/integrations/telegram/bot/", data,
|
||||||
content_type="application/json")
|
content_type="application/json")
|
||||||
|
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
@ -57,17 +57,17 @@ class AddTelegramTestCase(BaseTestCase):
|
|||||||
samples = ["", "{}"]
|
samples = ["", "{}"]
|
||||||
|
|
||||||
# text is missing
|
# text is missing
|
||||||
samples.append(json.dumps({
|
samples.append({
|
||||||
"message": {"chat": {"id": 123, "type": "group"}}
|
"message": {"chat": {"id": 123, "type": "group"}}
|
||||||
}))
|
})
|
||||||
|
|
||||||
# bad chat type
|
# bad chat type
|
||||||
samples.append(json.dumps({
|
samples.append({
|
||||||
"message": {
|
"message": {
|
||||||
"chat": {"id": 123, "type": "invalid"},
|
"chat": {"id": 123, "type": "invalid"},
|
||||||
"text": "/start"
|
"text": "/start"
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
|
||||||
for sample in samples:
|
for sample in samples:
|
||||||
r = self.client.post("/integrations/telegram/bot/", sample,
|
r = self.client.post("/integrations/telegram/bot/", sample,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user