def test_getCurrentPracticeTimeZone(self): role_user = self.mhluser self.assertEqual('', getCurrentPracticeTimeZone(role_user)) practice = PracticeLocation() local_tz = 'America/New_York' practice.time_zone = "America/Detroit" role_user.current_practice = practice self.assertEqual(local_tz, getCurrentPracticeTimeZone(role_user)) practice.time_zone = None role_user.current_practice = practice self.assertEqual('', getCurrentPracticeTimeZone(role_user))
def test_getCurrentPracticeTimeZone(self): role_user = self.mhluser self.assertEqual('', getCurrentPracticeTimeZone(role_user)) practice = PracticeLocation() local_tz = 'America/New_York' practice.time_zone = "America/Detroit" role_user.current_practice = practice self.assertEqual(local_tz, getCurrentPracticeTimeZone(role_user)) practice.time_zone = None role_user.current_practice = practice self.assertEqual('', getCurrentPracticeTimeZone(role_user))
def test_convert_dt_to_utz(self): local_tz = 'America/New_York' practice = PracticeLocation() practice.time_zone = local_tz dt = datetime(2013, 01, 29) local_tz = timezone(local_tz) local_dt = timezone(settings.TIME_ZONE).localize(dt, is_dst=None) cmp_dt = local_dt.astimezone(local_tz).replace(tzinfo=None) self.assertEqual(cmp_dt, convert_dt_to_utz(dt, self.mhluser, practice))
def test_convert_dt_to_utz(self): local_tz = 'America/New_York' practice = PracticeLocation() practice.time_zone = local_tz dt = datetime(2013, 01, 29) local_tz = timezone(local_tz) local_dt = timezone(settings.TIME_ZONE).localize(dt, is_dst=None) cmp_dt = local_dt.astimezone(local_tz).replace(tzinfo=None) self.assertEqual(cmp_dt, convert_dt_to_utz(dt, self.mhluser, practice))
def test_getCurrentTimeZoneForUser(self): tz = settings.TIME_ZONE self.assertEqual(tz, getCurrentTimeZoneForUser(None)) self.mhluser.time_zone = None self.assertEqual(tz, getCurrentTimeZoneForUser(None)) local_tz = 'America/New_York' role_user = self.mhluser practice = PracticeLocation() practice.time_zone = local_tz role_user.current_practice = practice self.assertEqual(local_tz, getCurrentTimeZoneForUser(self.mhluser, role_user)) self.assertEqual(local_tz, getCurrentTimeZoneForUser(self.mhluser, None, practice)) user_local_tz = 'America/Chicago' self.mhluser.time_zone = user_local_tz self.assertEqual(user_local_tz, getCurrentTimeZoneForUser(self.mhluser, role_user)) self.assertEqual(user_local_tz, getCurrentTimeZoneForUser(self.mhluser, None, practice))
def test_getCurrentTimeZoneForUser(self): tz = settings.TIME_ZONE self.assertEqual(tz, getCurrentTimeZoneForUser(None)) self.mhluser.time_zone = None self.assertEqual(tz, getCurrentTimeZoneForUser(None)) local_tz = 'America/New_York' role_user = self.mhluser practice = PracticeLocation() practice.time_zone = local_tz role_user.current_practice = practice self.assertEqual(local_tz, getCurrentTimeZoneForUser(self.mhluser, role_user)) self.assertEqual( local_tz, getCurrentTimeZoneForUser(self.mhluser, None, practice)) user_local_tz = 'America/Chicago' self.mhluser.time_zone = user_local_tz self.assertEqual(user_local_tz, getCurrentTimeZoneForUser(self.mhluser, role_user)) self.assertEqual( user_local_tz, getCurrentTimeZoneForUser(self.mhluser, None, practice))