Пример #1
0
    def test_pass_if_not_set_no_flag_exists(self):
        def view(request):
            return HttpResponse('ok')

        decorated = flag_required(self.flag_name, pass_if_set=False)(view)
        response = decorated(self.request)
        self.assertEqual(response.content, 'ok')
Пример #2
0
    def test_flag_required(self):
        def view(request):
            return HttpResponse("ok")

        decorated = flag_required("FLAG_ENABLED")(view)
        response = decorated(self.request)
        self.assertContains(response, "ok")
Пример #3
0
    def test_flag_required(self):
        def view(request):
            return HttpResponse('ok')

        decorated = flag_required('FLAG_ENABLED')(view)
        response = decorated(self.request)
        self.assertContains(response, 'ok')
Пример #4
0
    def test_pass_if_not_set_disabled(self):
        def view(request):
            return HttpResponse('ok')

        Flag.objects.create(key=self.flag_name, enabled_by_default=False)
        decorated = flag_required(self.flag_name, pass_if_set=False)(view)
        response = decorated(self.request)
        self.assertEqual(response.content, 'ok')
Пример #5
0
    def test_fallback_view(self):
        def fallback(request):
            return HttpResponse('fallback')

        decorator = flag_required(self.flag_name, fallback_view=fallback)
        decorated = decorator(self.view)
        response = decorated(self.request)
        self.assertEqual(response.content, 'fallback')
Пример #6
0
    def test_pass_if_not_set_no_flag_exists(self):
        def view(request):
            return HttpResponse('ok')

        decorated = flag_required(self.flag_name, pass_if_set=False)(view)
        response = decorated(self.request)
        if isinstance(response.content, str):
            content = response.content
        else:
            content = bytes.decode(response.content)
        self.assertEqual(content, 'ok')
Пример #7
0
    def test_pass_if_not_set_disabled(self):
        def view(request):
            return HttpResponse('ok')

        Flag.objects.create(key=self.flag_name, enabled_by_default=False)
        decorated = flag_required(self.flag_name, pass_if_set=False)(view)
        response = decorated(self.request)
        if isinstance(response.content, str):
            content = response.content
        else:
            content = bytes.decode(response.content)
        self.assertEqual(content, 'ok')
Пример #8
0
    def test_fallback_view(self):
        def fallback(request):
            return HttpResponse('fallback')

        decorator = flag_required(self.flag_name, fallback_view=fallback)
        decorated = decorator(self.view)
        response = decorated(self.request)
        if isinstance(response.content, str):
            content = response.content
        else:
            content = bytes.decode(response.content)
        self.assertEqual(content, 'fallback')
Пример #9
0
    def test_pass_if_not_set_fallback_view(self):
        Flag.objects.create(key=self.flag_name, enabled_by_default=True)

        def fallback(request):
            return HttpResponse('fallback')

        decorator = flag_required(
            self.flag_name,
            fallback_view=fallback,
            pass_if_set=False
        )

        decorated = decorator(self.view)
        response = decorated(self.request)
        self.assertEqual(response.content, 'fallback')
Пример #10
0
    def test_pass_if_not_set_fallback_view(self):
        Flag.objects.create(key=self.flag_name, enabled_by_default=True)

        def fallback(request):
            return HttpResponse('fallback')

        decorator = flag_required(
            self.flag_name,
            fallback_view=fallback,
            pass_if_set=False
        )

        decorated = decorator(self.view)
        response = decorated(self.request)
        if isinstance(response.content, str):
            content = response.content
        else:
            content = bytes.decode(response.content)
        self.assertEqual(content, 'fallback')
Пример #11
0
    url(r'^$', IndexView.as_view(**flag_kwargs), name='jobs'),
    url(r'^current-openings/$',
        CurrentOpeningsView.as_view(**flag_kwargs),
        name='current_openings'),
    url(r'application-process', FlaggedTemplateView.as_view(
        template_name='about-us/careers/application-process/index.html',
        **flag_kwargs
    )),
    url(r'working-at-cfpb/$', FlaggedTemplateView.as_view(
        template_name='about-us/careers/working-at-cfpb/index.html',
        **flag_kwargs
    )),
    url(r'students-and-graduates/$', FlaggedTemplateView.as_view(
        template_name='about-us/careers/students-and-graduates/index.html',
        **flag_kwargs
    )),

    # Deprecated /jobs/design-technology-fellows/.
    # Will keep it to keep the external links functioning.
    url(r'^fellowship_form_submit/$',
        fellowship_form_submit,
        name='fellowship_form_submit'),

    url(r'^(?P<pk>\d+)/$',
        flag_required(**flag_kwargs)(detail),
        name='detail-id-redirect'),
    url(r'^(?P<slug>.+?)/$',
        flag_required(**flag_kwargs)(detail),
        name='detail'),
]
Пример #12
0
 def test_pass_if_not_set_enabled(self):
     Flag.objects.create(key=self.flag_name, enabled_by_default=True)
     decorated = flag_required(self.flag_name, pass_if_set=False)(self.view)
     self.assertRaises(Http404, decorated, self.request)
     self.assertEqual(self.view.call_count, 0)
Пример #13
0
 def test_decorated_no_flag_exists(self):
     decorated = flag_required(self.flag_name)(self.view)
     self.assertRaises(Http404, decorated, self.request)
     self.assertEqual(self.view.call_count, 0)
Пример #14
0
 def test_pass_if_not_set_enabled(self):
     Flag.objects.create(key=self.flag_name, enabled_by_default=True)
     decorated = flag_required(self.flag_name, pass_if_set=False)(self.view)
     self.assertRaises(Http404, decorated, self.request)
     self.assertEqual(self.view.call_count, 0)
Пример #15
0
 def test_decorated_no_flag_exists(self):
     decorated = flag_required(self.flag_name)(self.view)
     self.assertRaises(Http404, decorated, self.request)
     self.assertEqual(self.view.call_count, 0)