tests, nicer error message for invalid schedule str

This commit is contained in:
Edwin Eefting
2021-04-13 16:42:55 +02:00
parent f9719ba87e
commit bef3be4955
2 changed files with 19 additions and 1 deletions

View File

@ -39,6 +39,10 @@ class ThinnerRule:
rule_str = rule_str.lower()
matches = re.findall("([0-9]*)([a-z]*)([0-9]*)([a-z]*)", rule_str)[0]
if '' in matches:
raise (Exception("Invalid schedule string: '{}'".format(rule_str)))
print(matches)
period_amount = int(matches[0])
period_unit = matches[1]
ttl_amount = int(matches[2])