示例#1
0
    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')
示例#2
0
    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'
        )
示例#3
0
    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))
示例#4
0
    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)
示例#5
0
    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))
示例#6
0
    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)
示例#7
0
    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))
示例#8
0
    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))
示例#9
0
    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())
示例#10
0
 def test():
     return hashbrown.is_active('things')
示例#11
0
    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())
示例#12
0
 def test():
     return hashbrown.is_active('things')