コード例 #1
0
ファイル: test_workrpt.py プロジェクト: tbarron/backscratcher
def parse_one_ymd(target, t):
    """
    test parse_ymd for one day
    """
    n = time.localtime()
    d = wr.week_diff(n[6], wr.day_offset(t))
    s = wr.stringify(time.localtime(wr.day_plus(d)))
    assert wr.parse_ymd(target) == s[0:3]
コード例 #2
0
ファイル: test_workrpt.py プロジェクト: tbarron/backscratcher
def test_next_tuesday():
    """
    Routine wr.next_tuesday() should return the date of next tuesday
    """
    pytest.debug_func()
    now = next_wkday(wr.day_offset('T'))
    nm = time.strftime('%Y.%m%d', time.localtime(now))
    lm = wr.next_tuesday()
    assert nm == lm
コード例 #3
0
ファイル: test_workrpt.py プロジェクト: tbarron/backscratcher
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
コード例 #4
0
ファイル: test_workrpt.py プロジェクト: tbarron/backscratcher
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
コード例 #5
0
ファイル: test_workrpt.py プロジェクト: tbarron/backscratcher
def test_day_offset():
    """
    Check each day offset
    """
    pytest.debug_func()
    assert wr.day_offset('f') == 3
    assert wr.day_offset('c') == 4
    assert wr.day_offset('M') == 0
    assert wr.day_offset('T') == 1
    assert wr.day_offset('W') == 2
    assert(wr.day_offset('t') == 3)
    assert(wr.day_offset('F') == 4)
    assert(wr.day_offset('s') == 5)
    assert(wr.day_offset('S') == 6)
    assert(wr.day_offset('') == 3)
    with pytest.raises(KeyError) as err:
        wr.day_offset('x')
    assert "'x'" in str(err)