Exemple #1
0
def test_display(days):
    d = ttcal.Today()
    d.mark = 'foo'
    assert 'foo' in d.display
    noday = ttcal.Day.from_idtag('d201502011')
    assert 'noday' in noday.display
    assert noday.special is False
Exemple #2
0
 def setUp(self):
     """SetUp default data for the tests.
     """
     self.day1 = ttcal.Day(date(2012, 4, 10))
     self.day2 = ttcal.Day(2012, 4, 8)
     self.day3 = ttcal.Day()
     self.today = ttcal.Today()
Exemple #3
0
def days():
    return [
        ttcal.Day(date(2012, 4, 10)),
        ttcal.Day(2012, 4, 8),
        ttcal.Day(),
        ttcal.Today(),
    ]
Exemple #4
0
def test_ctor(months):
    assert ttcal.Month() == ttcal.Today().Month

    with pytest.raises(ValueError):
        ttcal.Month(2012, 15)
Exemple #5
0
def test_contains():
    assert ttcal.Today() in ttcal.Month()

    with pytest.raises(KeyError):
        (ttcal.Month() + 2)[ttcal.Today()]
Exemple #6
0
def test_hash(months):
    assert hash(ttcal.Today().Month) == hash(ttcal.Month())
Exemple #7
0
def test_index(week):
    today = ttcal.Today()
    assert today in today.week
    assert today.week[0] <= today
Exemple #8
0
def test_hash(week):
    assert hash(week[0]) == hash(week[-1])
    assert len(set(hash(w)
                   for w in week)) == len(week) - 1  # first and last are equal
    assert hash(ttcal.Today() + 1) == hash(ttcal.Today().next())
Exemple #9
0
def test_until_today(week):
    w = ttcal.Today().week
    assert len(list(w.until_today())) == ttcal.Today() - w.first
    assert len(list(week[0].until_today())) == 7
Exemple #10
0
def test_current(week):
    assert week[0].current is False
    assert ttcal.Today().week.current
Exemple #11
0
def test_timetuple(days):
    assert isinstance(days[0].timetuple(), datetime)
    assert ttcal.Today().timetuple() == ttcal.Day().timetuple()