Exemplo n.º 1
0
    def test_add_list_of_interval(self):
        interval = Interval('test', ('PT0H', 'PT1H'))
        interval.interval = [('PT1H', 'PT2H')]

        assert interval.name == 'test'
        assert interval.start == ['PT0H', 'PT1H']
        assert interval.end == ['PT1H', 'PT2H']
Exemplo n.º 2
0
    def test_time_interval_start_before_end(get_time_intervals):
        with raises(ValueError) as excinfo:
            Interval('backwards', ('P1Y', 'P3M'))
        assert "A time interval must not end before it starts" in str(excinfo)

        interval = Interval('starts_ok', ('P0Y', 'P1M'))
        with raises(ValueError) as excinfo:
            interval.interval = ('P2M', 'P1M')
        assert "A time interval must not end before it starts" in str(excinfo)
Exemplo n.º 3
0
 def test_invalid_set_interval(self):
     interval = Interval('test', ('PT0H', 'PT1H'))
     with raises(ValueError) as excinfo:
         interval.interval = None
     msg = "A time interval must add either a single tuple or a list of tuples"
     assert msg in str(excinfo)