def test_human_readable_time(self): """Test that :func:`~app.models.Event.human_readable_time` properly formats event times into human readable time strings. """ from eventum.models import Event any_date = date(2015, 03, 31) for start_time, end_time, string in self.TIMES: event = Event(start_date=any_date, start_time=start_time, end_date=any_date, end_time=end_time, **self.EVENT_KWARGS) msg = self.ERROR_MSG.format('human readable time', string, event.human_readable_time()) self.assertEqual(event.human_readable_time(), string, msg=msg)
def test_human_readable_time(start_time, end_time, output): """Test that :func:`~app.models.Event.human_readable_time` properly formats event times into human readable time strings. """ any_date = dt.date(2015, 3, 31) event = Event(start_date=any_date, start_time=start_time, end_date=any_date, end_time=end_time) assert event.human_readable_time() == output
def test_event_starting_on_midnight(): """Test that events starting on midnight are properly formatted.""" event = Event(start_date=dt.date(2015, 4, 1), start_time=dt.time(0), end_date=dt.date(2015, 4, 1), end_time=dt.time(5, 30)) assert not event.is_multiday() assert event.human_readable_date() == "Wednesday, April 1" assert event.human_readable_time() == "12-5:30am"
def test_event_ending_on_midnight(): """Test that events ending on midnight are properly formatted.""" start_date, start_time = dt.date(2015, 3, 31), dt.time(22) end_date, end_time = dt.date(2015, 4, 1), dt.time(0) event = Event(start_date=start_date, start_time=start_time, end_date=end_date, end_time=end_time) assert not event.is_multiday() assert event.human_readable_date() == "Tuesday, March 31" assert event.human_readable_time() == "10pm-12am"
def test_event_starting_on_midnight(self): """Test that events starting on midnight are properly formatted.""" from eventum.models import Event start_date, start_time = date(2015, 04, 01), time(00) end_date, end_time = date(2015, 04, 01), time(05, 30) event = Event(start_date=start_date, start_time=start_time, end_date=end_date, end_time=end_time, **self.EVENT_KWARGS) self.assertFalse(event.is_multiday()) self.assertEqual(event.human_readable_date(), 'Wednesday, April 1') self.assertEqual(event.human_readable_time(), '12-5:30am')
def test_event_ending_on_midnight(self): """Test that events ending on midnight are properly formatted.""" from eventum.models import Event start_date, start_time = date(2015, 03, 31), time(22) end_date, end_time = date(2015, 04, 01), time(0) event = Event(start_date=start_date, start_time=start_time, end_date=end_date, end_time=end_time, **self.EVENT_KWARGS) self.assertFalse(event.is_multiday()) self.assertEqual(event.human_readable_date(), 'Tuesday, March 31') self.assertEqual(event.human_readable_time(), '10pm-12am')