|
|
@ -166,10 +166,20 @@ class UpdateCheckTestCase(BaseTestCase): |
|
|
|
self.assertEqual(r.status_code, 400) |
|
|
|
|
|
|
|
def test_it_rejects_non_string_desc(self): |
|
|
|
r = self.post( |
|
|
|
self.check.code, {"api_key": "X" * 32, "desc": 123} |
|
|
|
) |
|
|
|
r = self.post(self.check.code, {"api_key": "X" * 32, "desc": 123}) |
|
|
|
|
|
|
|
self.assertEqual(r.status_code, 400) |
|
|
|
|
|
|
|
def test_it_validates_cron_expression(self): |
|
|
|
self.check.kind = "cron" |
|
|
|
self.check.schedule = "5 * * * *" |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
samples = ["* invalid *", "1,2 3,* * * *", "0 0 31 2 *"] |
|
|
|
for sample in samples: |
|
|
|
r = self.post(self.check.code, {"api_key": "X" * 32, "schedule": sample}) |
|
|
|
self.assertEqual(r.status_code, 400, "Did not reject '%s'" % sample) |
|
|
|
|
|
|
|
# Schedule should be unchanged |
|
|
|
self.check.refresh_from_db() |
|
|
|
self.assertEqual(self.check.schedule, "5 * * * *") |