예제 #1
0
    def test_new_switch(self):
        assert not Switch.objects.filter(name='foo').exists()

        with override_switch('foo', active=True):
            assert switch_is_active('foo')

        with override_switch('foo', active=False):
            assert not switch_is_active('foo')

        assert not Switch.objects.filter(name='foo').exists()
예제 #2
0
    def test_switch_existed_and_was_NOT_active(self):
        Switch.objects.create(name='foo', active=False)

        with override_switch('foo', active=True):
            assert switch_is_active('foo')

        with override_switch('foo', active=False):
            assert not switch_is_active('foo')

        # make sure it didn't change 'active' value
        assert not Switch.objects.get(name='foo').active
예제 #3
0
        def _wrapped_view(request, *args, **kwargs):
            if switch_name.startswith('!'):
                active = not switch_is_active(switch_name[1:])
            else:
                active = switch_is_active(switch_name)

            if not active:
                response_to_redirect_to = get_response_to_redirect(redirect_to)
                if response_to_redirect_to:
                    return response_to_redirect_to
                else:
                    raise Http404

            return view(request, *args, **kwargs)
예제 #4
0
def switch(parser, token):
    condition = lambda request, name: switch_is_active(name)
    return WaffleNode.handle_token(parser, token, 'switch', condition)
예제 #5
0
 def test_disabled():
     assert not switch_is_active('foo')
예제 #6
0
 def test_enabled():
     assert switch_is_active('foo')
예제 #7
0
 def test_undecorated_method_is_set_properly_for_switch(self):
     self.assertFalse(switch_is_active('foo'))