def test_string_repr(self): """ Should have certain string representation """ expected = 'Vote for %(event)s: %(from)s - %(to)s' % { 'event': self.suggestion.event.title, 'from': localize(self.suggestion.from_date, 'd. F Y h:i'), 'to': localize(self.suggestion.to_date, 'd. F Y h:i'), } self.assertEqual(expected, force_text(self.vote))
def test_period_other_day(self): """ Period should be a certain string on different from and to dates """ self.event.from_date = now() self.event.to_date = self.event.from_date + timedelta(days=1) self.event.save() expected = '%s - %s' % (localize(self.event.from_date, 'd.m.'), localize(self.event.to_date, 'd.m.Y')) self.assertEqual(expected, self.event.get_period())
def test_string_repr_scheduled_single_day(self): """ Should have certain string representation if single day event """ expected = '%(event)s (%(date)s - %(end)s)' % { 'event': self.event.title, 'date': localize(self.event.from_date, 'd. F Y h:i'), 'end': localize(self.event.to_date, 'h:i'), } self.assertEqual(expected, force_text(self.event))
def test_string_repr_scheduled_single_day(self): """ Should have certain string representation if single day suggestion """ expected = '%(date)s - %(end)s (%(count)d)' % { 'date': localize(self.suggestion.from_date, 'd. F Y H:i'), 'end': localize(self.suggestion.to_date, 'H:i'), 'count': self.suggestion.count, } self.assertEqual(expected, force_text(self.suggestion))
def test_string_repr_scheduled_multi_day(self): """ Should have certain string representation if multi day event """ self.event.to_date += timedelta(days=1) self.event.save() expected = '%(event)s (%(from)s - %(to)s)' % { 'event': self.event.title, 'from': localize(self.event.from_date, 'd. F Y h:i'), 'to': localize(self.event.to_date, 'd. F Y h:i'), } self.assertEqual(expected, force_text(self.event))
def test_string_repr_scheduled_multi_day(self): """ Should have certain string representation if multi day suggestion """ self.suggestion.to_date += timedelta(days=1) self.suggestion.save() expected = '%(from)s - %(to)s (%(count)d)' % { 'from': localize(self.suggestion.from_date, 'd. F Y H:i'), 'to': localize(self.suggestion.to_date, 'd. F Y H:i'), 'count': self.suggestion.count, } self.assertEqual(expected, force_text(self.suggestion))
def test_period_same_day(self): """ Period should be same as from date on same day """ self.event.from_date = self.event.to_date self.event.save() expected = localize(self.event.from_date, 'd.m.Y') self.assertEqual(expected, self.event.get_period())
def test_localize_custom_format(self): """ Localize should return a certain localtime date_format when a custom format string is given """ format = 'd.m' expected = dateformat.format(localtime(self.event.from_date), format) self.assertEqual(expected, localize(self.event.from_date, format))
def test_localize_datetime_format(self): """ Localize should return a certain localtime date_format when a predefined format string is given """ format = 'DATETIME_FORMAT' expected = date_format(localtime(self.event.from_date), format) self.assertEqual(expected, localize(self.event.from_date, format))
def test_localize_no_format(self): """ Localize should return a certain localtime date_format when no format string is given """ format = None expected = date_format(localtime(self.event.from_date), format) self.assertEqual(expected, localize(self.event.from_date, format))