Esempio n. 1
0
 def test_token_snapped_to_ending_of_month_edge_case_1(self, mocked, *args):
     # Snap `now` to the beginning of the month
     mocked.return_value = get_test_date('2018-12-01 00:00:00')
     payload = 'now@M'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-31 23:59:59')
     self.assertEqual(expected, actual)
Esempio n. 2
0
 def test_token_snapped_to_ending_of_business_week(self):
     payload = 'now@bw'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2019, 2, 22, 23, 59, 59, tzinfo=pytz.UTC))
Esempio n. 3
0
 def test_token_snapped_to_ending_of_hour(self):
     payload = 'now@h'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 59, 59, tzinfo=pytz.UTC))
Esempio 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_date(payload)
     self.compare_datetime(actual,
                           datetime(2019, 2, 18, 0, 0, 0, tzinfo=pytz.UTC))
Esempio n. 5
0
 def test_token_with_amount_modifiers(self, *args):
     payload = 'now-5d+1h'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-10 11:12:34')
     self.assertEqual(expected, actual)
Esempio n. 6
0
 def test_token_snapped_to_ending_of_month(self):
     payload = 'now@M'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 30, 23, 59, 59, tzinfo=pytz.UTC))
Esempio n. 7
0
 def test_day_of_week_token_can_be_combined_1(self):
     payload = 'now@sun/d'
     actual = token_to_date(payload)
     self.compare_datetime(actual,
                           datetime(2016, 12, 4, 0, 0, 0, tzinfo=pytz.UTC))
Esempio n. 8
0
 def test_token_snapped_to_following_sunday(self):
     payload = 'now@sun'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 12, 4, 12, 55, 23, tzinfo=pytz.UTC))
Esempio n. 9
0
 def test_token_snapped_to_ending_of_month(self, *args):
     payload = 'now@M'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-31 23:59:59')
     self.assertEqual(expected, actual)
Esempio n. 10
0
 def test_token_snapped_to_ending_of_hour(self, *args):
     payload = 'now@h'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-15 10:59:59')
     self.assertEqual(expected, actual)
Esempio n. 11
0
 def test_token_snapped_to_ending_of_business_week(self, *args):
     payload = 'now@bw'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-14 23:59:59')
     self.assertEqual(expected, actual)
Esempio n. 12
0
 def test_token_snapped_to_beginning_of_business_week(self, *args):
     payload = 'now/bw'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-10 00:00:00')
     self.assertEqual(expected, actual)
Esempio n. 13
0
 def test_token_snapped_to_beginning_of_month(self, *args):
     payload = 'now/M'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-01 00:00:00')
     self.assertEqual(expected, actual)
Esempio n. 14
0
 def test_token_snapped_to_beginning_of_minute(self, *args):
     payload = 'now/m'
     actual = token_to_date(payload)
     expected = get_test_date('2018-12-15 10:12:00')
     self.assertEqual(expected, actual)
Esempio n. 15
0
 def test_token_snapped_to_previous_sunday(self):
     payload = 'now/sun'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 27, 12, 55, 23, tzinfo=pytz.UTC))
Esempio n. 16
0
 def test_default_token(self):
     payload = 'now'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 55, 23, tzinfo=pytz.UTC))
Esempio n. 17
0
 def test_token_snapped_to_prev_monday_yields_today(self):
     # Today is Monday. Therefore, should snap to today.
     payload = 'now/mon'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 55, 23, tzinfo=pytz.UTC))
Esempio n. 18
0
 def test_token_with_amount_modifiers(self):
     payload = 'now-5d+1h'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 23, 13, 55, 23, tzinfo=pytz.UTC))
Esempio n. 19
0
 def test_token_snapped_to_following_monday(self):
     # Today is Saturday. Therefore, should snap to today.
     payload = 'now@mon'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 28, 12, 55, 23, tzinfo=pytz.UTC))
Esempio n. 20
0
 def test_token_snapped_to_beginning_of_day(self):
     payload = 'now/d'
     actual = token_to_date(payload)
     self.compare_datetime(actual,
                           datetime(2016, 11, 28, 0, 0, 0, tzinfo=pytz.UTC))
Esempio n. 21
0
 def test_day_of_week_token_can_be_combined_2(self):
     payload = 'now/sun@d'
     actual = token_to_date(payload)
     self.compare_datetime(
         actual, datetime(2016, 11, 27, 23, 59, 59, tzinfo=pytz.UTC))
Esempio n. 22
0
 def test_token_snapped_to_beginning_of_month(self):
     payload = 'now/M'
     actual = token_to_date(payload)
     self.compare_datetime(actual,
                           datetime(2019, 2, 1, 0, 0, 0, tzinfo=pytz.UTC))
Esempio n. 23
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_date(payload)
     self.compare_datetime(
         actual, datetime(2018, 12, 31, 23, 59, 59, tzinfo=pytz.UTC))
Esempio n. 24
0
    def test_default_token(self, *args):
        payload = 'now'
        actual = token_to_date(payload)
        expected = NOW_MOCKED

        self.assertEqual(expected, actual)