示例#1
0
    def test_switch_inactive_all_sites_override(self):
        name = 'myswitch'
        Switch.objects.create(name=name, active=False, site=self.site1)
        self.assertFalse(waffle.switch_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertFalse(waffle.switch_is_active(get(), name))
示例#2
0
    def test_sample_inactive_all_sites_override(self):
        name = 'mysample'
        Sample.objects.create(name=name, percent='0.0', site=self.site1)
        self.assertFalse(waffle.sample_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertFalse(waffle.sample_is_active(get(), name))
示例#3
0
    def test_sample_site_default(self):
        name = "sample"
        sample = Sample.objects.create(name=name, percent="100.0")  # no site given

        self.assertTrue(waffle.sample_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertTrue(waffle.sample_is_active(get(), name))
示例#4
0
    def test_switch_site_default(self):
        name = "myswitch"
        switch = Switch.objects.create(name=name, active=True)  # no site given

        self.assertTrue(waffle.switch_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertTrue(waffle.switch_is_active(get(), name))
示例#5
0
    def test_flag_all_sites_override(self):
        name = 'sample'
        Flag.objects.create(name=name, everyone=True, site=self.site1)

        self.assertTrue(waffle.flag_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertTrue(waffle.flag_is_active(get(), name))
示例#6
0
    def test_sample_by_site(self):
        name = "sample"
        sample1 = Sample.objects.create(name=name, percent="100.0", site=self.site1)
        sample2 = Sample.objects.create(name=name, percent="0.0", site=self.site2)

        self.assertTrue(waffle.sample_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertFalse(waffle.sample_is_active(get(), name))
示例#7
0
    def test_switch_by_site(self):
        """ test that we can get different switch values by site """
        name = 'myswitch'
        Switch.objects.create(name=name, active=True, site=self.site1,
                              all_sites_override=False)
        self.assertTrue(waffle.switch_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertFalse(waffle.switch_is_active(get(), name))
示例#8
0
    def test_switch_by_multisite(self):
        name = "myswitch"
        switch1 = Switch.objects.create(name=name, active=True, site=self.site1,
                                        all_sites_override=False)
        switch1.site.add(self.site2)
        switch1.site.add(self.site3)

        self.assertTrue(waffle.switch_is_active(get(), name))
        with self.settings(SITE_ID=2):
            self.assertTrue(waffle.switch_is_active(get(), name))
        with self.settings(SITE_ID=3):
            self.assertTrue(waffle.switch_is_active(get(), name))
        with self.settings(SITE_ID=4):
            self.assertFalse(waffle.switch_is_active(get(), name))
示例#9
0
    def test_non_unicode_chars_in_headers(self):
        request = get()

        request.META[u'HTTP_USER_AGENT'] = 'Не unicode строка'
        self.assertIsInstance(RedisStorage(request), RedisStorage)

        request.META[u'HTTP_USER_AGENT'] = u'Unicode строка'
        self.assertIsInstance(RedisStorage(request), RedisStorage)
示例#10
0
    def test_flag_by_site(self):
        name = "myflag"
        flag1 = Flag.objects.create(name=name, everyone=True, site=self.site1)
        flag2 = Flag.objects.create(name=name, everyone=False, site=self.site2)
        request = get()

        response = process_request(request, views.flag_in_view)
        self.assertContains(response, b"on")

        with self.settings(SITE_ID=2):
            response = process_request(request, views.flag_in_view)
            self.assertContains(response, b"off")
示例#11
0
    def test_flag_by_site(self):
        name = 'myflag'
        flag1 = Flag.objects.create(name=name, everyone=True, site=self.site1)
        flag2 = Flag.objects.create(name=name, everyone=False, site=self.site2)
        request = get()

        response = process_request(request, views.flag_in_view)
        eq_(b'on', response.content)

        with self.settings(SITE_ID=2):
            response = process_request(request, views.flag_in_view)
            eq_(b'off', response.content)
示例#12
0
    def test_flag_by_site(self):
        name = 'myflag'
        flag1 = Flag.objects.create(name=name, everyone=True, site=self.site1,
                                    all_sites_override=False)
        request = get()

        response = process_request(request, views.flag_in_view)
        self.assertContains(response, b'on')

        with self.settings(SITE_ID=2):
            response = process_request(request, views.flag_in_view)
            self.assertContains(response, b'off')
示例#13
0
 def test_switch_inactive_no_bound_sites(self):
     switch = Switch.objects.create(name='myswitch', active=True,
                                    all_sites_override=False)
     self.assertFalse(waffle.switch_is_active(get(), switch.name))