Example #1
0
def test_compare(week):
    assert ttcal.Week.weeknum() > week[0]
    assert ttcal.Week.weeknum(2015, 40) > ttcal.Week.weeknum(2015, 4)
    d14 = Day(2014, 10, 4)
    d15 = Day(2015, 10, 4)
    d16 = Day(2016, 10, 4)
    w = ttcal.Week.weeknum(2, 2015)
    y14 = ttcal.Year(2014)
    y15 = ttcal.Year(2015)
    y16 = ttcal.Year(2016)

    assert w > y14
    assert w < y16
    assert w == y15
    assert not w != y15

    assert w < d16
    assert w <= d16
    assert w > d14
    assert w >= d14
    assert w == Day(2015, 1, 8)

    assert not w < None
    assert not w <= None
    assert not w == None
    assert not w >= None
    assert not w > None
Example #2
0
def test_int_years():
    assert ttcal.Year(2015) < 2016
    assert ttcal.Year(2015) <= 2016
    assert ttcal.Year(2016) > 2015
    assert ttcal.Year(2016) >= 2015
    assert ttcal.Year(2016) != 2015
    assert ttcal.Year(2016) == 2016
Example #3
0
def test_set_dumps():
    assert jason.json_eval(jason.dumps(1)) == 1
    assert jason.json_eval(jason.dumps(set())) == []
    assert jason.json_eval(jason.dumps({1, 2})) == [1, 2]
    assert jason.json_eval(jason.dumps(ttcal.Year(2017))) == {
        'year': 2017,
        'kind': 'YEAR'
    }
    assert jason.dumps(ttcal.Duration.parse('1:10:01')) == '"@duration:4201"'
    assert jason.dumps(datetime.date(2019, 3, 15)) == '"@date:2019-03-15"'
    assert jason.json_eval(
        jason.dumps(datetime.time(hour=1, minute=10, second=1))) == {
            'hour': 1,
            'minute': 10,
            'second': 1,
            'microsecond': 0,
            'kind': 'TIME'
        }

    class Foo(object):
        __slots__ = ['a', 'b']

    with pytest.raises(TypeError):
        jason.dumps(Foo())  # not JSON serializable
Example #4
0
def test_call(months):
    assert months[0].first == ttcal.Year(2012).april(1)
Example #5
0
def test_Year(months):
    """Test the Year method.
    """
    assert months[0].Year == ttcal.Year(2012)
    assert months[0].Month == months[0]
Example #6
0
def test_idtag(week):
    assert week[0].idtag() == 'w20124'
    assert week[1].idtag() == 'w%d1' % ttcal.Year()
    assert week[2].idtag() == 'w201252'
Example #7
0
def test_prev(years):
    """Test of the prev method.
    """
    assert years[0].prev() == ttcal.Year(2004)
Example #8
0
def test_sub(years):
    """Test of the __sub__ method.
    """
    assert years[0] - 3 == ttcal.Year(2002)
Example #9
0
def test_add(years):
    """Test of the __add__ method.
    """
    assert years[0] + 5 == ttcal.Year(2010)
    assert 5 + years[0] == ttcal.Year(2010)
Example #10
0
def test_hash(years):
    assert hash(years[0]) == hash(ttcal.Year(2005))
Example #11
0
def test_mark(years):
    y = ttcal.Year()
    m = y.middle
    y.mark(m, 'foo')
    # assert 'foo' in m.display
    assert True  # ??
Example #12
0
def test_cmp(years):
    """Test the compare methods.
    """
    assert years[1] == ttcal.Year(date.today().year)
    assert not (years[0] == years[2])
    # assert not (years[0] == 'foo')
    assert ttcal.Year(2015) < ttcal.Year(2016)
    assert ttcal.Year(2015) <= ttcal.Year(2016)
    assert ttcal.Year(2016) > ttcal.Year(2015)
    assert ttcal.Year(2016) >= ttcal.Year(2015)
    assert ttcal.Year(2015) == ttcal.Week.weeknum(1, 2015)
    assert not ttcal.Year(2015) in [None]
    assert not ttcal.Year(2015) < None
    assert not ttcal.Year(2015) <= None
    assert not ttcal.Year(2015) is None
    assert not ttcal.Year(2015) > None
    assert not ttcal.Year(2015) >= None
Example #13
0
def years():
    return [
        ttcal.Year(2005),
        ttcal.Year(),
        ttcal.Year(2025),
    ]
Example #14
0
def test_next(years):
    """Test of the next method.
    """
    assert years[0].next() == ttcal.Year(2006)
Example #15
0
 def test_Year(self):
     """Test of the Year property.
     """
     year = ttcal.Year(2012)
     assert self.day1.Year == year