def main(): cron_spec = parse_args(argv) timetable = CronTimeTable(minute=parse_field(Interval.MINUTE, cron_spec.minute), hour=parse_field(Interval.HOUR, cron_spec.hour), day_of_month=parse_field(Interval.DAY_OF_MONTH, cron_spec.day_of_month), month=parse_field(Interval.MONTH, cron_spec.month), day_of_week=parse_field(Interval.DAY_OF_WEEK, cron_spec.day_of_week), command=cron_spec.command) timetable_string = format_timetable(timetable) print(timetable_string)
def test_parse_field_invalid_range(): with raises(ValidationException, match='Invalid range'): parse_field(Interval.MINUTE, "5-1")
def test_parse_field_invalid_value(): with raises(ValidationException, match='Invalid value'): parse_field(Interval.MINUTE, "100")
def test_parse_field_unexpected(): with raises(ParsingException, match='Could not parse token'): parse_field(Interval.MINUTE, "*/-")
def test_parse_field_short(): with raises(ParsingException, match='end of input'): parse_field(Interval.MINUTE, "*/")
def test_parse_field(interval, value, expected_parsed_values): parsed_values = parse_field(interval, value) assert parsed_values == expected_parsed_values