def test_clean_valid_end_date(self):
        """
        If an event's end date is after its start date or doesn't exist, clean should not raise a
        ValidationError.
        """
        event = EventFactory.build(start_date=date(2011, 1, 1), end_date=date(2013, 1, 1))
        event.clean()

        event = EventFactory.build(start_date=date(2011, 1, 1), end_date=None)
        event.clean()
    def test_clean_invalid_end_date(self):
        """
        If an event's end date is on or before its start date, clean should raise a
        ValidationError.
        """
        event = EventFactory.build(start_date=date(2011, 1, 1), end_date=date(2010, 1, 1))
        self.assertRaises(ValidationError, event.clean)

        event = EventFactory.build(start_date=date(2010, 1, 1), end_date=date(2010, 1, 1))
        self.assertRaises(ValidationError, event.clean)
Beispiel #3
0
    def test_clean_valid_end_date(self):
        """
        If an event's end date is after its start date or doesn't exist, clean should not raise a
        ValidationError.
        """
        event = EventFactory.build(start_date=date(2011, 1, 1),
                                   end_date=date(2013, 1, 1))
        event.clean()

        event = EventFactory.build(start_date=date(2011, 1, 1), end_date=None)
        event.clean()
Beispiel #4
0
    def test_clean_invalid_end_date(self):
        """
        If an event's end date is on or before its start date, clean should raise a
        ValidationError.
        """
        event = EventFactory.build(start_date=date(2011, 1, 1),
                                   end_date=date(2010, 1, 1))
        self.assertRaises(ValidationError, event.clean)

        event = EventFactory.build(start_date=date(2010, 1, 1),
                                   end_date=date(2010, 1, 1))
        self.assertRaises(ValidationError, event.clean)
Beispiel #5
0
    def test_event_filter(self):
        """
        The events shown on the university page should be limited to events occurring on or after
        the current date, and should be ordered by start date.
        """
        event1 = EventFactory.create(start_date=date(2010, 1, 6))
        event2 = EventFactory.create(start_date=date(2010, 2, 4))
        event3 = EventFactory.create(start_date=date(2010, 1, 3),
                                     end_date=date(2010, 1, 8))
        event4 = EventFactory.create(start_date=date(2010, 1, 2),
                                     end_date=date(2010, 1, 6))

        # Events that shouldn't be included.
        EventFactory.create(start_date=date(2010, 1, 2))
        EventFactory.create(start_date=date(2010, 1, 2),
                            end_date=date(2010, 1, 5))

        with patch('careers.university.views.date') as mock_date:
            mock_date.today.return_value = date(2010, 1, 6)

            with patch('careers.university.views.render') as render:
                response = views.index(self.factory.get('/'))

        eq_(response, render.return_value)
        context = render.call_args[0][2]
        eq_(list(context['events']), [event4, event3, event1, event2])
Beispiel #6
0
 def test_date_different_months(self):
     """If the event starts in one month and ends in another, show both dates."""
     event = EventFactory.build(start_date=date(2012, 5, 5),
                                end_date=date(2012, 6, 9))
     self.assertEqual(
         event.date, '{may} 5, 2012 - {jun} 9, 2012'.format(may=MAY,
                                                            jun=JUN))
Beispiel #7
0
    def test_event_filter(self):
        """
        The events shown on the university page should be limited to
        events occurring on or after the current date, and should be
        ordered by start date.
        """
        event1 = EventFactory.create(start_date=date(2010, 1, 6))
        event2 = EventFactory.create(start_date=date(2010, 2, 4))
        event3 = EventFactory.create(start_date=date(2010, 1, 3), end_date=date(2010, 1, 8))
        event4 = EventFactory.create(start_date=date(2010, 1, 2), end_date=date(2010, 1, 6))

        # Events that shouldn't be included.
        EventFactory.create(start_date=date(2010, 1, 2))
        EventFactory.create(start_date=date(2010, 1, 2), end_date=date(2010, 1, 5))

        with patch('careers.university.views.date') as mock_date:
            mock_date.today.return_value = date(2010, 1, 6)
            response, context = self._index()

        eq_(list(context['events']), [event4, event3, event1, event2])
Beispiel #8
0
    def test_event_filter(self):
        """
        The events shown on the university page should be limited to
        events occurring on or after the current date, and should be
        ordered by start date.
        """
        event1 = EventFactory.create(start_date=date(2010, 1, 6))
        event2 = EventFactory.create(start_date=date(2010, 2, 4))
        event3 = EventFactory.create(start_date=date(2010, 1, 3),
                                     end_date=date(2010, 1, 8))
        event4 = EventFactory.create(start_date=date(2010, 1, 2),
                                     end_date=date(2010, 1, 6))

        # Events that shouldn't be included.
        EventFactory.create(start_date=date(2010, 1, 2))
        EventFactory.create(start_date=date(2010, 1, 2),
                            end_date=date(2010, 1, 5))

        with patch('careers.university.views.date') as mock_date:
            mock_date.today.return_value = date(2010, 1, 6)
            response, context = self._index()

        self.assertEqual(list(context['events']),
                         [event4, event3, event1, event2])
Beispiel #9
0
 def test_unicode(self):
     event = EventFactory.build(start_date=date(2011, 5, 5),
                                name='Foo',
                                location='Bar')
     eq_(unicode(event), u'Foo, Bar - {may} 5, 2011'.format(may=MAY))
Beispiel #10
0
 def test_date_same_month(self):
     """If the event starts and ends in the same month, display a shortened date."""
     event = EventFactory.build(start_date=date(2012, 5, 5),
                                end_date=date(2012, 5, 9))
     eq_(event.date, '{may} 5-9, 2012'.format(may=MAY))
Beispiel #11
0
 def test_date_no_end_date(self):
     """If the event has no end date, just display the start date."""
     event = EventFactory.build(start_date=date(2012, 5, 5))
     eq_(event.date, '{may} 5, 2012'.format(may=MAY))
 def test_unicode(self):
     event = EventFactory.build(start_date=date(2011, 5, 5), name='Foo', location='Bar')
     self.assertEqual(unicode(event), u'Foo, Bar - {may} 5, 2011'.format(may=MAY))
 def test_date_different_months(self):
     """If the event starts in one month and ends in another, show both dates."""
     event = EventFactory.build(start_date=date(2012, 5, 5), end_date=date(2012, 6, 9))
     self.assertEqual(event.date, '{may} 5, 2012 - {jun} 9, 2012'.format(may=MAY, jun=JUN))
 def test_date_same_month(self):
     """If the event starts and ends in the same month, display a shortened date."""
     event = EventFactory.build(start_date=date(2012, 5, 5), end_date=date(2012, 5, 9))
     self.assertEqual(event.date, '{may} 5-9, 2012'.format(may=MAY))
 def test_date_no_end_date(self):
     """If the event has no end date, just display the start date."""
     event = EventFactory.build(start_date=date(2012, 5, 5))
     self.assertEqual(event.date, '{may} 5, 2012'.format(may=MAY))