def test_format_reservation_start_day_before(self): reservation = self.create_reservation(datetime(2017, 12, 24, 12), datetime(2017, 12, 25, 6)) self.assertEqual(ReservationCalendarComponentView.format_reservation(reservation, pytz.timezone( timezone.get_default_timezone_name()).localize(datetime(2017, 12, 25))), { 'reservation': reservation, 'start_percentage': 0, 'start_time': "00:00", 'end_time': "05:00", "length": 25 })
def test_format_reservation_end_day_after(self): reservation = self.create_reservation(datetime(2017, 12, 25, 12), datetime(2017, 12, 26, 3)) self.assertEqual(ReservationCalendarComponentView.format_reservation(reservation, pytz.timezone( timezone.get_default_timezone_name()).localize(datetime(2017, 12, 25))), { 'reservation': reservation, 'start_percentage': 50, 'start_time': '11:00', 'end_time': "23:59", 'length': 50 - 100 / 1440 })
def test_format_reservation_start_end_same_day(self): reservation = self.create_reservation(datetime(2017, 12, 25, 12), datetime(2017, 12, 25, 18)) self.assertEqual(ReservationCalendarComponentView.format_reservation(reservation, pytz.timezone( timezone.get_default_timezone_name()).localize(datetime(2017, 12, 25))), { 'reservation': reservation, 'start_percentage': 50, 'start_time': "11:00", 'end_time': "17:00", 'length': 25 })
def test_format_reservation_end_day_after(self): date = pytz.timezone(timezone.get_default_timezone_name()).localize( datetime.combine(timezone.now().date() + timedelta(days=1), datetime.min.time())) reservation = self.create_reservation(date + timedelta(hours=12), date + timedelta(days=1, hours=4)) self.assertEqual(ReservationCalendarComponentView.format_reservation(reservation, date), { 'reservation': reservation, 'start_percentage': 50, 'start_time': '11:00', 'end_time': "23:59", 'length': 50 - 100 / 1440 })
def test_format_reservation_start_day_before(self): date = pytz.timezone(timezone.get_default_timezone_name()).localize( datetime.combine(timezone.now().date() + timedelta(days=1), datetime.min.time())) reservation = self.create_reservation(date + timedelta(hours=12), date + timedelta(days=1, hours=6)) self.assertEqual(ReservationCalendarComponentView.format_reservation(reservation, date + timedelta(days=1)), { 'reservation': reservation, 'start_percentage': 0, 'start_time': "00:00", 'end_time': "05:00", "length": 25 })
def test_format_reservation_end_day_after(self, get_default_timezone_mock): # Set default timezone to UTC get_default_timezone_mock.return_value = timezone.get_fixed_timezone(0) date = pytz.timezone("UTC").localize( datetime.combine(timezone.now().date() + timedelta(days=1), datetime.min.time())) reservation = self.create_reservation( date + timedelta(hours=12), date + timedelta(days=1, hours=4)) self.assertEqual( ReservationCalendarComponentView.format_reservation( reservation, date), { 'reservation': reservation, 'start_percentage': 50, 'start_time': '12:00', 'end_time': "23:59", 'length': 50 - 100 / 1440 })
def test_format_reservation_start_day_before(self, get_default_timezone_mock): # Set default timezone to UTC get_default_timezone_mock.return_value = timezone.get_fixed_timezone(0) date = pytz.timezone("UTC").localize( datetime.combine(timezone.now().date() + timedelta(days=1), datetime.min.time())) reservation = self.create_reservation( date + timedelta(hours=12), date + timedelta(days=1, hours=6)) self.assertEqual( ReservationCalendarComponentView.format_reservation( reservation, date + timedelta(days=1)), { 'reservation': reservation, 'start_percentage': 0, 'start_time': "00:00", 'end_time': "06:00", "length": 25 })