Browse Source

Bump croniter version to 1.0.2

pull/474/head
Pēteris Caune 4 years ago
parent
commit
b9997137a6
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 11 additions and 2 deletions
  1. +5
    -0
      hc/front/tests/test_cron_preview.py
  2. +4
    -0
      hc/lib/jsonschema.py
  3. +1
    -1
      hc/lib/tests/test_jsonschema.py
  4. +1
    -1
      requirements.txt

+ 5
- 0
hc/front/tests/test_cron_preview.py View File

@ -48,3 +48,8 @@ class CronPreviewTestCase(BaseTestCase):
payload = {"schedule": "0 3 * * *", "tz": "Europe/Riga"}
r = self.client.post("/checks/cron_preview/", payload)
self.assertNotContains(r, "Invalid cron expression", status_code=200)
def test_it_handles_feb_29(self):
payload = {"schedule": "0 0 29 2 *", "tz": "UTC"}
r = self.client.post("/checks/cron_preview/", payload)
self.assertContains(r, "Feb 29")

+ 4
- 0
hc/lib/jsonschema.py View File

@ -22,6 +22,10 @@ def validate(obj, schema, obj_name="value"):
raise ValidationError("%s is too long" % obj_name)
if schema.get("format") == "cron":
try:
# Does it have 5 components?
if len(obj.split()) != 5:
raise ValueError()
# Does croniter accept the schedule?
it = croniter(obj)
# Can it calculate the next datetime?


+ 1
- 1
hc/lib/tests/test_jsonschema.py View File

@ -74,7 +74,7 @@ class JsonSchemaTestCase(TestCase):
validate("baz", {"enum": ["foo", "bar"]})
def test_it_checks_cron_format(self):
samples = ["x * * * *", "0 0 31 2 *"]
samples = ["x * * * *", "0 0 31 2 *", "* * * * * *"]
for sample in samples:
with self.assertRaises(ValidationError):
validate(sample, {"type": "string", "format": "cron"})


+ 1
- 1
requirements.txt View File

@ -1,5 +1,5 @@
cron-descriptor==1.2.24
croniter==0.3.31
croniter==1.0.2
Django==3.1.5
django-compressor==2.4
fido2


Loading…
Cancel
Save