Exemple #1
0
 def setUp(self):
     """
     Assume we have:
     - server with `America/Chicago` timezone
     - app with `America/New_York` timezone (if Django timezone support enabled)
     - current timezone `Europe/Moscow` (if active)
     - then it is 2016-01-01T00:00:00 at server
     """
     self.condition_set = UTCTodayConditionSet()
     self.server_dt = datetime.datetime(2016, 1, 1, 0, 0, 0)
     self.server_tz = pytz.timezone('America/Chicago')
     self.server_dt_aware = self.server_tz.localize(self.server_dt)
     self.server_tz_offset = -6
     self.utc_dt = self.server_dt - datetime.timedelta(
         hours=self.server_tz_offset)
Exemple #2
0
class UTCTodayConditionSetTests(TestCase):
    def setUp(self):
        """
        Assume we have:
        - server with `America/Chicago` timezone
        - app with `America/New_York` timezone (if Django timezone support enabled)
        - current timezone `Europe/Moscow` (if active)
        - then it is 2016-01-01T00:00:00 at server
        """
        self.condition_set = UTCTodayConditionSet()
        self.server_dt = datetime.datetime(2016, 1, 1, 0, 0, 0)
        self.server_tz = pytz.timezone('America/Chicago')
        self.server_dt_aware = self.server_tz.localize(self.server_dt)
        self.server_tz_offset = -6
        self.utc_dt = self.server_dt - datetime.timedelta(
            hours=self.server_tz_offset)

    @override_settings(USE_TZ=True, TIME_ZONE="America/New_York")
    @timezone.override('Europe/Moscow')
    def test_use_tz_with_active(self):
        with freeze_time(self.server_dt_aware,
                         tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(
                None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=True, TIME_ZONE="America/New_York")
    @timezone.override(None)
    def test_use_tz_no_active(self):
        with freeze_time(self.server_dt_aware,
                         tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(
                None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=False, TIME_ZONE=None)
    @timezone.override('Europe/Moscow')
    def test_no_use_tz_with_active(self):
        with freeze_time(self.server_dt_aware,
                         tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(
                None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=False, TIME_ZONE=None)
    @timezone.override(None)
    def test_no_use_tz_without_active(self):
        with freeze_time(self.server_dt_aware,
                         tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(
                None, 'now_is_on_or_after') == self.utc_dt
Exemple #3
0
class UTCTodayConditionSetTests(TestCase):
    def setUp(self):
        """
        Assume we have:
        - server with `America/Chicago` timezone
        - app with `America/New_York` timezone (if Django timezone support enabled)
        - current timezone `Europe/Moscow` (if active)
        - then it is 2016-01-01T00:00:00 at server
        """
        self.condition_set = UTCTodayConditionSet()
        self.server_dt = datetime.datetime(2016, 1, 1, 0, 0, 0)
        self.server_tz = pytz.timezone('America/Chicago')
        self.server_dt_aware = self.server_tz.localize(self.server_dt)
        self.server_tz_offset = -6
        self.utc_dt = self.server_dt - datetime.timedelta(hours=self.server_tz_offset)

    @override_settings(USE_TZ=True, TIME_ZONE="America/New_York")
    @timezone.override('Europe/Moscow')
    def test_use_tz_with_active(self):
        with freeze_time(self.server_dt_aware, tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=True, TIME_ZONE="America/New_York")
    @timezone.override(None)
    def test_use_tz_no_active(self):
        with freeze_time(self.server_dt_aware, tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=False, TIME_ZONE=None)
    @timezone.override('Europe/Moscow')
    def test_no_use_tz_with_active(self):
        with freeze_time(self.server_dt_aware, tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(None, 'now_is_on_or_after') == self.utc_dt

    @override_settings(USE_TZ=False, TIME_ZONE=None)
    @timezone.override(None)
    def test_no_use_tz_without_active(self):
        with freeze_time(self.server_dt_aware, tz_offset=self.server_tz_offset):
            assert self.condition_set.get_field_value(None, 'now_is_on_or_after') == self.utc_dt
Exemple #4
0
 def setUp(self):
     """
     Assume we have:
     - server with `America/Chicago` timezone
     - app with `America/New_York` timezone (if Django timezone support enabled)
     - current timezone `Europe/Moscow` (if active)
     - then it is 2016-01-01T00:00:00 at server
     """
     self.condition_set = UTCTodayConditionSet()
     self.server_dt = datetime.datetime(2016, 1, 1, 0, 0, 0)
     self.server_tz = pytz.timezone('America/Chicago')
     self.server_dt_aware = self.server_tz.localize(self.server_dt)
     self.server_tz_offset = -6
     self.utc_dt = self.server_dt - datetime.timedelta(hours=self.server_tz_offset)