Allow setting 30 day timeouts and grace times through API.

This commit is contained in:
Pēteris Caune 2018-03-17 09:43:55 +02:00
parent 1794c322e6
commit 166115ebfb
2 changed files with 17 additions and 4 deletions

View File

@ -3,8 +3,8 @@ check = {
"properties": {
"name": {"type": "string", "maxLength": 100},
"tags": {"type": "string", "maxLength": 500},
"timeout": {"type": "number", "minimum": 60, "maximum": 604800},
"grace": {"type": "number", "minimum": 60, "maximum": 604800},
"timeout": {"type": "number", "minimum": 60, "maximum": 2592000},
"grace": {"type": "number", "minimum": 60, "maximum": 2592000},
"schedule": {"type": "string", "format": "cron", "maxLength": 100},
"tz": {"type": "string", "format": "timezone", "maxLength": 36},
"channels": {"type": "string"},

View File

@ -42,13 +42,26 @@ class CreateCheckTestCase(BaseTestCase):
self.assertTrue("schedule" not in doc)
self.assertTrue("tz" not in doc)
self.assertEqual(Check.objects.count(), 1)
check = Check.objects.get()
self.assertEqual(check.name, "Foo")
self.assertEqual(check.tags, "bar,baz")
self.assertEqual(check.timeout.total_seconds(), 3600)
self.assertEqual(check.grace.total_seconds(), 60)
def test_30_days_works(self):
r = self.post({
"api_key": "abc",
"name": "Foo",
"timeout": 2592000,
"grace": 2592000
})
self.assertEqual(r.status_code, 201)
check = Check.objects.get()
self.assertEqual(check.timeout.total_seconds(), 2592000)
self.assertEqual(check.grace.total_seconds(), 2592000)
def test_it_accepts_api_key_in_header(self):
payload = json.dumps({"name": "Foo"})
r = self.client.post(self.URL, payload,
@ -103,7 +116,7 @@ class CreateCheckTestCase(BaseTestCase):
expected_fragment="timeout is too small")
def test_it_rejects_large_timeout(self):
self.post({"api_key": "abc", "timeout": 604801},
self.post({"api_key": "abc", "timeout": 2592001},
expected_fragment="timeout is too large")
def test_it_rejects_non_number_timeout(self):