forked from GithubBackups/healthchecks
Allow setting 30 day timeouts and grace times through API.
This commit is contained in:
parent
1794c322e6
commit
166115ebfb
@ -3,8 +3,8 @@ check = {
|
|||||||
"properties": {
|
"properties": {
|
||||||
"name": {"type": "string", "maxLength": 100},
|
"name": {"type": "string", "maxLength": 100},
|
||||||
"tags": {"type": "string", "maxLength": 500},
|
"tags": {"type": "string", "maxLength": 500},
|
||||||
"timeout": {"type": "number", "minimum": 60, "maximum": 604800},
|
"timeout": {"type": "number", "minimum": 60, "maximum": 2592000},
|
||||||
"grace": {"type": "number", "minimum": 60, "maximum": 604800},
|
"grace": {"type": "number", "minimum": 60, "maximum": 2592000},
|
||||||
"schedule": {"type": "string", "format": "cron", "maxLength": 100},
|
"schedule": {"type": "string", "format": "cron", "maxLength": 100},
|
||||||
"tz": {"type": "string", "format": "timezone", "maxLength": 36},
|
"tz": {"type": "string", "format": "timezone", "maxLength": 36},
|
||||||
"channels": {"type": "string"},
|
"channels": {"type": "string"},
|
||||||
|
@ -42,13 +42,26 @@ class CreateCheckTestCase(BaseTestCase):
|
|||||||
self.assertTrue("schedule" not in doc)
|
self.assertTrue("schedule" not in doc)
|
||||||
self.assertTrue("tz" not in doc)
|
self.assertTrue("tz" not in doc)
|
||||||
|
|
||||||
self.assertEqual(Check.objects.count(), 1)
|
|
||||||
check = Check.objects.get()
|
check = Check.objects.get()
|
||||||
self.assertEqual(check.name, "Foo")
|
self.assertEqual(check.name, "Foo")
|
||||||
self.assertEqual(check.tags, "bar,baz")
|
self.assertEqual(check.tags, "bar,baz")
|
||||||
self.assertEqual(check.timeout.total_seconds(), 3600)
|
self.assertEqual(check.timeout.total_seconds(), 3600)
|
||||||
self.assertEqual(check.grace.total_seconds(), 60)
|
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):
|
def test_it_accepts_api_key_in_header(self):
|
||||||
payload = json.dumps({"name": "Foo"})
|
payload = json.dumps({"name": "Foo"})
|
||||||
r = self.client.post(self.URL, payload,
|
r = self.client.post(self.URL, payload,
|
||||||
@ -103,7 +116,7 @@ class CreateCheckTestCase(BaseTestCase):
|
|||||||
expected_fragment="timeout is too small")
|
expected_fragment="timeout is too small")
|
||||||
|
|
||||||
def test_it_rejects_large_timeout(self):
|
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")
|
expected_fragment="timeout is too large")
|
||||||
|
|
||||||
def test_it_rejects_non_number_timeout(self):
|
def test_it_rejects_non_number_timeout(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user