示例#1
0
    def test_proxy_attr_access_to_underlying_date(self):
        subject = RelativeDate.fromdate(date(2016, 3, 8))
        target = date(2016, 3, 8)

        assert subject.year == target.year
        assert subject.day == target.day
        assert subject.month == target.month
示例#2
0
    def test_radd_with_unaccounted_type(self):
        class Thing(object):
            def __radd__(self, other):
                return other + timedelta(days=5)

        assert RelativeDate.fromdate(date(2016, 1, 1)) + Thing() == date(
            2016, 1, 6)
示例#3
0
    def test_relative_dates_compare_underlying_date(self):
        off_by_one = RelativeDate(timedelta(days=1), clock=FakeDate.today)

        assert off_by_one == off_by_one
        assert off_by_one != RelativeDate(timedelta(0), clock=FakeDate.today)
        assert off_by_one != RelativeDate.fromdate(date(2015, 1, 1),
                                                   timedelta(days=1))
示例#4
0
    def test_proxy_attr_access_to_underlying_date(self):
        subject = RelativeDate.fromdate(date(2016, 3, 8))
        target = date(2016, 3, 8)

        assert subject.year == target.year
        assert subject.day == target.day
        assert subject.month == target.month
示例#5
0
    def test_relative_delta_with_relative_date(self):
        rd = RelativeDate.fromdate(date(2000, 1, 1), offset=relativedelta(years=16))

        assert rd == date(2016, 1, 1)
示例#6
0
    def test_radd_with_unaccounted_type(self):
        class Thing(object):
            def __radd__(self, other):
                return other + timedelta(days=5)

        assert RelativeDate.fromdate(date(2016, 1, 1)) + Thing() == date(2016, 1, 6)
示例#7
0
    def test_replace_with_offset_argument(self):
        rd = RelativeDate.fromdate(TODAY).replace(offset=timedelta(days=5))

        assert rd == RelativeDate.fromdate(TODAY, offset=timedelta(days=5))
示例#8
0
    def test_replace_with_date_arguments(self):
        rd = RelativeDate.fromdate(date(2016, 1, 1)).replace(year=2015, day=2, month=2)

        assert rd.as_date() == date(2015, 2, 2)
示例#9
0
 def test_proxy_boolness(self):
     assert bool(RelativeDate.fromdate(TODAY))
示例#10
0
 def test_proxy_boolness(self):
     assert bool(RelativeDate.fromdate(TODAY))
示例#11
0
    def test_sub_relative_delta_instances(self):
        rd = RelativeDate.fromdate(date(2016, 1, 1),
                                   offset=relativedelta(days=1))

        assert rd - rd == RelativeDate.fromdate(date(2016, 1, 1),
                                                offset=relativedelta())
示例#12
0
    def test_relative_delta_with_relative_date(self):
        rd = RelativeDate.fromdate(date(2000, 1, 1),
                                   offset=relativedelta(years=16))

        assert rd == date(2016, 1, 1)
示例#13
0
    def test_replace_with_offset_argument(self):
        rd = RelativeDate.fromdate(TODAY).replace(offset=timedelta(days=5))

        assert rd == RelativeDate.fromdate(TODAY, offset=timedelta(days=5))
示例#14
0
    def test_replace_with_date_arguments(self):
        rd = RelativeDate.fromdate(date(2016, 1, 1)).replace(year=2015,
                                                             day=2,
                                                             month=2)

        assert rd.as_date() == date(2015, 2, 2)
示例#15
0
 def test_sub_relative_delta_instances(self):
     rd = RelativeDate.fromdate(date(2016, 1, 1), offset=relativedelta(days=1))
     assert rd - rd == RelativeDate.fromdate(
         date(2016, 1, 1), offset=relativedelta()
     )
示例#16
0
    def test_textual_representations(self):
        target = date(2016, 3, 8)
        subject = RelativeDate.fromdate(target)

        assert str(subject) == str(target)
示例#17
0
    def test_relative_dates_compare_underlying_date(self):
        off_by_one = RelativeDate(timedelta(days=1), clock=FakeDate.today)

        assert off_by_one == off_by_one
        assert off_by_one != RelativeDate(timedelta(0), clock=FakeDate.today)
        assert off_by_one != RelativeDate.fromdate(date(2015, 1, 1), timedelta(days=1))
示例#18
0
    def test_textual_representations(self):
        target = date(2016, 3, 8)
        subject = RelativeDate.fromdate(target)

        assert str(subject) == str(target)