def test_flag_for_other_site_disabled(self): flag = Flag.objects.create(key=self.flag_name) other_site = Site.objects.create(is_default_site=False, root_page_id=self.site.root_page_id) FlagState.objects.create(flag=flag, site=other_site, enabled=True) self.assertFalse(flag_enabled(self.request, self.flag_name))
def inner(request, *args, **kwargs): enabled = flag_enabled(request, flag_name) if (condition and enabled) or (not condition and not enabled): return func(request, *args, **kwargs) elif fallback is not None: return fallback(request, *args, **kwargs) else: raise Http404
def inner(request, *args, **kwargs): enabled = flag_enabled(request, flag_name) if (enabled and pass_if_set) or (not enabled and not pass_if_set): return func(request, *args, **kwargs) elif fallback_view is not None: return fallback_view(request) else: raise Http404
def test_flag_true_enabled(self): flag = Flag.objects.create(key=self.flag_name) FlagState.objects.create(flag=flag, site=self.site, enabled=True) self.assertTrue(flag_enabled(self.request, self.flag_name))
def test_flag_false_disabled(self): flag = Flag.objects.create(key=self.flag_name) FlagState.objects.create(flag=flag, site=self.site, enabled=False) self.assertFalse(flag_enabled(self.request, self.flag_name))
def test_flag_default_true_enabled(self): Flag.objects.create(key=self.flag_name, enabled_by_default=True) self.assertTrue(flag_enabled(self.request, self.flag_name))
def test_flag_default_false_disabled(self): Flag.objects.create(key=self.flag_name, enabled_by_default=False) self.assertFalse(flag_enabled(self.request, self.flag_name))
def test_no_flag_should_be_disabled(self): self.assertFalse(flag_enabled(self.request, self.flag_name))
def test_flag_enabled_no_request(self): self.assertTrue(flag_enabled('FLAG_ENABLED'))
def test_flag_enabled_false(self): self.assertFalse(flag_enabled('FLAG_DISABLED', request=self.request))
def test_flag_enabled_true(self): self.assertTrue(flag_enabled('FLAG_ENABLED', request=self.request))