示例#1
0
def test_interpret_options_week_end():
    """
    Verify mutual exclusion of -w and -e
    """
    pytest.debug_func()
    (o, a) = wr.make_option_parser(['-w', 'T', '-e', '2009.0501'])
    with pytest.raises(bscr.Error) as err:
        wr.interpret_options(o)
    assert '--week and --start or --end are not compatible' in str(err)
示例#2
0
def test_interpret_options_last_start():
    """
    Verify mutual exclusion of -l and -s
    """
    pytest.debug_func()
    (o, a) = wr.make_option_parser(['-l', '-s', '2009.0501'])
    with pytest.raises(bscr.Error) as err:
        wr.interpret_options(o)
    assert '--last and --start or --end are not compatible' in str(err)
示例#3
0
def test_interpret_options_since():
    """
    Verify that option --since works as expected
    """
    pytest.debug_func()
    (o, a) = wr.make_option_parser(['--since', '2009.0501'])
    (start, end) = wr.interpret_options(o)
    assert start == '2009.0501'
    assert end == time.strftime('%Y.%m%d')

    (o, a) = wr.make_option_parser(['-s', '2010.0101', '-S', '2010.1231'])
    with pytest.raises(bscr.Error) as err:
        wr.interpret_options(o)
    assert '--since and --start are not compatible' in str(err)
示例#4
0
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
示例#5
0
def test_interpret_options_end():
    """
    If the user provides option -e <date>, wr.interpret_options should return a
    start date one week before and an end date of <date>
    """
    pytest.debug_func()
    (o, a) = wr.make_option_parser(['-e', '2009.0401'])
    (start, end) = wr.interpret_options(o)
    start_should_be = '2009.0326'
    end_should_be = '2009.0401'
    assert start_should_be == start
    assert end_should_be == end
示例#6
0
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