Example #1
0
    def test_with_logged_in_user(self):
        """
        test that page loads if there user is available
        """
        url = reverse('flexbookings:lesson_detail', args=[self.lesson.slug])
        request = self.factory.get(url)
        # Set the user on the request
        request.user = self.user
        view = EventDetailView.as_view()
        resp = view(request, slug=self.lesson.slug, ev_type='lesson')

        self.assertEqual(resp.status_code, 200)
        self.assertEquals(resp.context_data['type'], 'lesson')
        self.assertNotIn('Sign in to book', resp.rendered_content)
    def test_lesson_and_event_format(self):
        """
        Test correct context returned for lessons and events
        """
        event = mommy.make_recipe(
            'flex_bookings.future_WS', name='Wshop', cost=10,
            booking_open=True,)

        lesson = mommy.make_recipe(
            'flex_bookings.future_EV', name='Lesson',
            cost=10, booking_open=True,
        )

        resp = self._get_response(self.user, event, 'event')
        self.assertEquals(resp.context_data['type'], 'workshop')

        url = reverse('flexbookings:lesson_detail', args=[lesson.slug])
        request = self.factory.get(url)
        request.user = self.user
        view = EventDetailView.as_view()
        resp = view(request, slug=lesson.slug, ev_type='lesson')
        self.assertEquals(resp.context_data['type'], 'lesson')
Example #3
0
 def _get_event_detail(self, user, event, ev_type):
     url = reverse('flexbookings:event_detail', args=[event.slug])
     request = self.factory.get(url)
     request.user = user
     view = EventDetailView.as_view()
     return view(request, slug=event.slug, ev_type=ev_type)
Example #4
0
 ),
 # url(r'^booking/update/(?P<pk>\d+)/cancelled/$',
 #     'flex_bookings.views.update_booking_cancelled',
 #     name='update_booking_cancelled'),
 url(r'^booking/cancel/(?P<pk>\d+)/$', BookingDeleteView.as_view(),
     name='delete_booking'),
 url(r'^events/(?P<event_slug>[\w-]+)/cancellation-period-past/$',
     cancellation_period_past, name='cancellation_period_past'),
 url(r'^booking/(?P<event_slug>[\w-]+)/duplicate/$',
     duplicate_booking, name='duplicate_booking'),
 url(r'^booking/(?P<event_slug>[\w-]+)/full/$', fully_booked,
     name='fully_booked'),
 url(r'^booking/(?P<event_slug>[\w-]+)/new/$', BookingCreateView.as_view(),
     name='book_event'),
 url(
     r'^workshops/(?P<slug>[\w-]+)/$', EventDetailView.as_view(),
     {'ev_type': 'event'}, name='event_detail'
 ),
 url(
     r'^workshops/$', EventListView.as_view(), {'ev_type': 'events'},
     name='events'
 ),
 url(
     r'^classes/(?P<slug>[\w-]+)/$',  EventDetailView.as_view(),
     {'ev_type': 'lesson'}, name='lesson_detail'),
 url(
     r'^classes/$', EventListView.as_view(), {'ev_type': 'lessons'},
     name='lessons'
 ),
 url(r'^booking/(?P<event_slug>[\w-]+)/not-open/$', booking_not_open,
     name='not_open'),