Ejemplo n.º 1
0
 def test_token_snapped_to_ending_of_hour(self):
     payload = 'now@h'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 59, 59, tzinfo=pytz.UTC))
Ejemplo n.º 2
0
 def test_token_snapped_to_ending_of_week(self):
     payload = 'now@w'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2019, 2, 24, 22, 59, 59, tzinfo=pytz.UTC))
Ejemplo n.º 3
0
 def test_token_snapped_to_beginning_of_month(self):
     payload = 'now/M'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(actual,
                           datetime(2019, 1, 31, 23, 0, 0, tzinfo=pytz.UTC))
Ejemplo n.º 4
0
 def test_token_snapped_to_beginning_of_business_week(self):
     # TODO: bw is a highly relative concept ;)
     payload = 'now/bw'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(actual,
                           datetime(2019, 2, 17, 23, 0, 0, tzinfo=pytz.UTC))
Ejemplo n.º 5
0
 def test_token_snapped_to_beginning_of_minute(self):
     payload = 'now/m'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 55, 0, tzinfo=pytz.UTC))
Ejemplo n.º 6
0
 def test_token_with_amount_modifiers(self):
     payload = 'now-5d+1h'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2016, 11, 23, 13, 55, 23, tzinfo=pytz.UTC))
Ejemplo n.º 7
0
 def test_default_token(self):
     payload = 'now'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 55, 23, tzinfo=pytz.UTC))
Ejemplo n.º 8
0
 def test_token_snapped_to_ending_of_month_edge_case_2(self):
     # Snap `now` to the beginning of the month
     payload = 'now@M'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2019, 1, 31, 22, 59, 59, tzinfo=pytz.UTC))
Ejemplo n.º 9
0
 def test_token_snapped_to_ending_of_year_edge_case_1(self):
     # Snap `now` to the beginning of the year
     payload = 'now@Y'
     actual = token_to_utc_date(payload, tz='Europe/Madrid')
     self.compare_datetime(
         actual, datetime(2018, 12, 31, 22, 59, 59, tzinfo=pytz.UTC))