Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 def test_last_second(self):
     now = datetime.datetime.now(UTC)
     now -= datetime.timedelta(seconds=1)
     assert is_interest_current({"endDate": now.isoformat()}) is False
Ejemplo n.º 3
0
 def test_this_date(self):
     assert (
         is_interest_current({"endDate": str(dateutil.utils.today(UTC).date())})
         is True
     )
Ejemplo n.º 4
0
 def test_yesterday(self):
     assert (
         is_interest_current({"endDate": str(dateutil.utils.today(UTC).year - 1)})
         is False
     )
Ejemplo n.º 5
0
 def test_future_datetime_tzz(self):
     assert is_interest_current({"endDate": "2112-05-07T01:02:03.0004Z"}) is True
Ejemplo n.º 6
0
 def test_this_YYYY_MM(self):
     today = dateutil.utils.today(UTC)
     assert (
         is_interest_current({"endDate": "{}-{}".format(today.year, today.month)})
         is True
     )
Ejemplo n.º 7
0
 def test_future_YYYY_MM(self):
     assert is_interest_current({"endDate": "2112-05"}) is True
Ejemplo n.º 8
0
 def test_future_date(self):
     assert is_interest_current({"endDate": "2112-05-07"}) is True
Ejemplo n.º 9
0
 def test_past_date(self):
     assert is_interest_current({"endDate": "2018-05-07"}) is False
Ejemplo n.º 10
0
 def test_past_YYYY_MM(self):
     assert is_interest_current({"endDate": "2018-05"}) is False
Ejemplo n.º 11
0
 def test_bad_endDate_value(self):
     assert is_interest_current({"endDate": "bad"}) is False
Ejemplo n.º 12
0
 def test_empty_dict(self):
     assert is_interest_current({}) is True
Ejemplo 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