def test_now(self):
     now = datetime.datetime.now(UTC)
     # Add a second because comparison is now instaneous
     now += datetime.timedelta(seconds=1)
     assert is_interest_current({"endDate": now.isoformat()}) is True
 def test_last_second(self):
     now = datetime.datetime.now(UTC)
     now -= datetime.timedelta(seconds=1)
     assert is_interest_current({"endDate": now.isoformat()}) is False
 def test_this_date(self):
     assert (
         is_interest_current({"endDate": str(dateutil.utils.today(UTC).date())})
         is True
     )
 def test_yesterday(self):
     assert (
         is_interest_current({"endDate": str(dateutil.utils.today(UTC).year - 1)})
         is False
     )
 def test_future_datetime_tzz(self):
     assert is_interest_current({"endDate": "2112-05-07T01:02:03.0004Z"}) is True
 def test_this_YYYY_MM(self):
     today = dateutil.utils.today(UTC)
     assert (
         is_interest_current({"endDate": "{}-{}".format(today.year, today.month)})
         is True
     )
 def test_future_YYYY_MM(self):
     assert is_interest_current({"endDate": "2112-05"}) is True
 def test_future_date(self):
     assert is_interest_current({"endDate": "2112-05-07"}) is True
 def test_past_date(self):
     assert is_interest_current({"endDate": "2018-05-07"}) is False
Exemplo n.º 10
0
 def test_past_YYYY_MM(self):
     assert is_interest_current({"endDate": "2018-05"}) is False
Exemplo n.º 11
0
 def test_bad_endDate_value(self):
     assert is_interest_current({"endDate": "bad"}) is False
Exemplo n.º 12
0
 def test_empty_dict(self):
     assert is_interest_current({}) is True
Exemplo n.º 13
0
 def test_last_second_no_tz(self):
     now = datetime.datetime.now(UTC)
     now.replace(tzinfo=None)
     now -= datetime.timedelta(seconds=1)
     assert is_interest_current({"endDate": now.isoformat()}) is False