def wsl(target, offset, now, should_start, should_end): """ Routine week_starting_last() takes time index *now*, *target* weekday (0 = Monday), and *offset* seconds. It computes, say,"last Monday" from *now*, adds *offset* seconds, and returns a tuple containing the day indicated in %Y.%m%d format and a week later in the same format. """ (s, e) = wr.week_starting_last(target, offset, now) assert s == should_start assert e == should_end
def test_interpret_options_defaults(): """ Check default start and end times. """ pytest.debug_func() (o, a) = wr.make_option_parser([]) (start, end) = wr.interpret_options(o) assert not o.dayflag (start_should_be, x) = wr.week_starting_last(wr.day_offset('M'), 0) end_should_be = time.strftime('%Y.%m%d', time.localtime()) assert start == start_should_be assert end == end_should_be
def test_interpret_options_dayflag(): """ Verify that setting the day flag does not disrupt the default start/end time """ pytest.debug_func() (o, a) = wr.make_option_parser(["-d"]) (start, end) = wr.interpret_options(o) assert o.dayflag (start_should_be, x) = wr.week_starting_last(wr.day_offset('M'), 0) end_should_be = time.strftime('%Y.%m%d', time.localtime()) assert start_should_be == start assert end_should_be == end