def test_default_switches_on_settings(self): self.assertTrue(hashbrown.is_active('test')) self.assertFalse(hashbrown.is_active('things')) self.assertEqual( Switch.objects.get(label='things').description, 'This does some things')
def test_default_switches_on_settings(self): self.assertTrue(hashbrown.is_active('test')) self.assertFalse(hashbrown.is_active('things')) self.assertEqual( Switch.objects.get(label='things').description, 'This does some things' )
def test_is_active_enabled_globally_for_users(self): user = get_user_model().objects.create( email='*****@*****.**', username='******') Switch.objects.create(label='some_feature', globally_active=True) with self.assertNumQueries(1): # get self.assertTrue(hashbrown.is_active('some_feature', user=user))
def test_is_active_with_existing_enabled_flag(self): Switch.objects.create(label='some_feature', globally_active=True) with self.assertNumQueries(1): # get self.assertTrue(hashbrown.is_active('some_feature')) self.assertEqual( Switch.objects.filter(label='some_feature').count(), 1)
def test_is_active_enabled_globally_for_users(self): user = get_user_model().objects.create(email='*****@*****.**', username='******') Switch.objects.create(label='some_feature', globally_active=True) with self.assertNumQueries(1): # get self.assertTrue(hashbrown.is_active('some_feature', user=user))
def test_is_active_for_different_user_with_flag_enabled(self): user_1 = get_user_model().objects.create( email='*****@*****.**', username='******') user_2 = get_user_model().objects.create( email='*****@*****.**', username='******') switch = Switch.objects.create( label='some_feature', globally_active=False) switch.users.add(user_1) with self.assertNumQueries(2): # get, check user self.assertFalse(hashbrown.is_active('some_feature', user=user_2))
def test_is_active_for_different_user_with_flag_enabled(self): user_1 = get_user_model().objects.create(email='*****@*****.**', username='******') user_2 = get_user_model().objects.create(email='*****@*****.**', username='******') switch = Switch.objects.create(label='some_feature', globally_active=False) switch.users.add(user_1) with self.assertNumQueries(2): # get, check user self.assertFalse(hashbrown.is_active('some_feature', user=user_2))
def test_is_active_without_existing_flag_creates_it(self): self.assertFalse(Switch.objects.filter(label='some_feature').exists()) self.assertFalse(hashbrown.is_active('some_feature')) self.assertTrue(Switch.objects.filter(label='some_feature').exists())
def test(): return hashbrown.is_active('things')