Ejemplo n.º 1
0
    def test_PilotDetail(self):
        url = reverse('pilot_detail', kwargs={'username': '******'})
        request = self.factory.get(url)

        # Anonymous
        request.user = AnonymousUser()
        response = PilotDetail.as_view()(request, username='******')
        self.assertEqual(response.status_code, 302)

        # Not anonymous, pilot does not exist
        request.user = self.regular_user
        with self.assertRaises(Http404):
            _ = PilotDetail.as_view()(request, username='******')

        # Not anonymous, pilot exists
        request.user = self.regular_user
        helper.create_pilot(username='******')
        response = PilotDetail.as_view()(request, username='******')
        self.assertIsNotNone(response.context_data['pilot'])
        self.assertIsNotNone(response.context_data['checkouts'])
Ejemplo n.º 2
0
    def test_PilotDetail(self):
        url = reverse('pilot_detail', kwargs={'username':'******'})
        request = self.factory.get(url)

        # Anonymous
        request.user = AnonymousUser()
        response = PilotDetail.as_view()(request, username='******')
        self.assertEqual(response.status_code, 302)

        # Not anonymous, pilot does not exist
        request.user = self.regular_user
        with self.assertRaises(Http404):
            _ = PilotDetail.as_view()(request, username='******')

        # Not anonymous, pilot exists
        request.user = self.regular_user
        helper.create_pilot(username='******')
        response = PilotDetail.as_view()(request, username='******')
        self.assertIsNotNone(response.context_data['pilot'])
        self.assertIsNotNone(response.context_data['checkouts'])
Ejemplo n.º 3
0
 url(r'^emerald/', include(admin.site.urls)),
 # Checkouts app views
 url(
     regex=r'^$',
     # No 'home' view at this time, but we may want to add one later. For
     # now, provide a redirect to a popular view instead.
     view=lambda x: redirect('checkout_filter', permanent=False),
 ),
 url(
     regex=r'^pilots/$',
     view=PilotList.as_view(),
     name='pilot_list',
 ),
 url(
     regex=r'^pilots/(?P<username>\w+)/$',
     view=PilotDetail.as_view(),
     name='pilot_detail',
 ),
 url(
     regex=r'^airstrips/$',
     view=AirstripList.as_view(),
     name='airstrip_list',
 ),
 url(
     regex=r'^airstrips/(?P<ident>\w+)/$',
     view=AirstripDetail.as_view(),
     name='airstrip_detail',
 ),
 url(
     regex=r'^bases/$',
     view=BaseList.as_view(),
Ejemplo n.º 4
0
 url(r'^emerald/', include(admin.site.urls)),
 # Checkouts app views
 url(
     regex=r'^$',
     # No 'home' view at this time, but we may want to add one later. For
     # now, provide a redirect to a popular view instead.
     view=lambda x: redirect('checkout_filter', permanent=False),
 ),
 url(
     regex=r'^pilots/$',
     view=PilotList.as_view(),
     name='pilot_list',
 ),
 url(
     regex=r'^pilots/(?P<username>\w+)/$',
     view=PilotDetail.as_view(),
     name='pilot_detail',
 ),
 url(
     regex=r'^airstrips/$',
     view=AirstripList.as_view(),
     name='airstrip_list',
 ),
 url(
     regex=r'^airstrips/(?P<ident>\w+)/$',
     view=AirstripDetail.as_view(),
     name='airstrip_detail',
 ),
 url(
     regex=r'^bases/$',
     view=BaseList.as_view(),