示例#1
0
 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))
示例#2
0
 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())
示例#3
0
 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))
示例#4
0
 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))
示例#5
0
 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))
示例#6
0
 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))
示例#7
0
 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())
示例#8
0
 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))
示例#9
0
 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))
示例#10
0
 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))