Beispiel #1
0
def test_week_find_day(text, exp):
    """
    Coverage for week.find_day()
    """
    pytest.debug_func()
    w = nldt.week()
    assert w.find_day(text) == exp
Beispiel #2
0
def test_week_match_weekdays(inp, exp):
    """
    Verify that the weekday matching regex works
    """
    pytest.debug_func()
    w = nldt.week()
    assert re.findall(w.match_weekdays(), inp, re.I) == exp
Beispiel #3
0
def test_week_fullname(inpl, exp):
    """
    Verify mapping index and abbreviations to full names
    """
    pytest.debug_func()
    w = nldt.week()
    for inp in inpl:
        assert w.fullname(inp) == exp
Beispiel #4
0
def test_week_index(inp, exp):
    """
    Verify that weekday names are mapped to the correct numbers
    """
    pytest.debug_func()
    w = nldt.week()
    for inps in inp:
        assert w.index(inps) == exp
Beispiel #5
0
def test_week_backdiff(inps, inpe, exp):
    """
    week.backdiff() returns the number of days between two week days, jumping
    backward. The returned value ranges between 1 and 7
    """
    pytest.debug_func()
    w = nldt.week()
    assert w.backdiff(inps, inpe) == exp
Beispiel #6
0
def test_week_day_list():
    """
    Verify nldt.week.day_list()
    """
    pytest.debug_func()
    w = nldt.week()
    dl = w.day_list()
    for wname in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
                  'Saturday', 'Sunday']:
        assert wname.lower() in dl
Beispiel #7
0
def test_week_constructor():
    """
    nldt.week() constructor should return an object with dict of months
    """
    pytest.debug_func()
    w = nldt.week()
    assert hasattr(w, '_dict')
    for midx in range(0, 7):
        assert midx in w._dict
    for wname in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']:
        assert wname in w._dict
Beispiel #8
0
def test_week_day_number():
    """
    Test week.day_number()
    """
    pytest.debug_func()
    w = nldt.week()
    sat = nldt.moment("2000-01-01")
    sun = nldt.moment("2000-01-02")

    assert w.day_number(sat.epoch()) == 5        # payload
    assert w.day_number(sat) == 5                # payload

    with pytest.raises(TypeError) as err:
        # payload
        w.day_number(txt['xpr-tod']) == 14
    assert txt["err-argmore"] in str(err)

    assert w.day_number(sat, count='mon1') == 6    # payload
    assert w.day_number(sun, count='mon1') == 7    # payload

    assert w.day_number(sat, count='sun0') == 6    # payload
    assert w.day_number(sun, count='sun0') == 0    # payload