def test_invalid_unit(): with pytest.raises(ConfigurationError): Timeline.parse_check({ 'name': 'x', 'schedule': { 'every': 2, 'unit': 'olympics' }, })
def test_sample_schedule(): rule = Timeline.parse_check( {'schedule': { 'every': 1, 'unit': 'week', 'at': '07:40', }}) assert rule == [TimelineRule(interval=1, unit='week', at='07:40')]
def test_invalid_time(): with pytest.raises(ConfigurationError): print(Timeline.parse_check({ 'name': 'x', 'schedule': { 'every': 'day', 'at': 'noon', }, }))
def test_invalid_every(): with pytest.raises(ConfigurationError): print(Timeline.parse_check({ 'name': 'x', 'schedule': { 'every': 'single', # every must be integer 'unit': 'minute', }, }))
def test_invalid_schedule(): with pytest.raises(ConfigurationError): Timeline.parse_check({ 'name': 'x', 'schedule': 'daily', })
def test_empty_period(): rule = Timeline.parse_check({'name': 'x'}) assert rule == [TimelineRule(interval=300, unit='seconds', at=None)]
def test_period_parse(): rule = Timeline.parse_check({'period': '1 hour'}) assert rule == [TimelineRule(interval=3600, unit='seconds', at=None)]