Ejemplo n.º 1
0
 def test_find_domains_with_toggle_enabled(self):
     domain_toggle = StaticToggle(
         'domain_toggle',
         'A test toggle',
         TAG_CUSTOM,
         [NAMESPACE_USER]
     )
     domain, = find_domains_with_toggle_enabled(domain_toggle)
     self.assertEqual(domain, self.domain)
Ejemplo n.º 2
0
 def test_find_users_with_toggle_enabled(self):
     user_toggle = StaticToggle(
         'user_toggle',
         'A test toggle',
         TAG_CUSTOM,
         [NAMESPACE_USER]
     )
     users = find_users_with_toggle_enabled(user_toggle)
     self.assertEqual(set(users), set(self.users))
Ejemplo n.º 3
0
 def test_user_namespace(self):
     user_toggle = StaticToggle(
         'user_namespace_toggle',
         'A test toggle',
         TAG_CUSTOM,
         [NAMESPACE_USER]
     )
     user_toggle.set(self.user.username, True, namespace=NAMESPACE_USER)
     self.assertTrue(user_toggle.enabled(self.user.username))
     self.assertFalse(user_toggle.enabled(self.second_user.username))
     self.assertTrue(user_toggle.enabled_for_request(self.request))
     self.assertFalse(user_toggle.enabled_for_request(self.second_request))
Ejemplo n.º 4
0
 def test_domain_namespace(self):
     domain_toggle = StaticToggle(
         'domain_namespace_toggle',
         'A test toggle',
         TAG_CUSTOM,
         [NAMESPACE_DOMAIN]
     )
     domain_toggle.set(self.domain.name, True, namespace=NAMESPACE_DOMAIN)
     self.assertTrue(domain_toggle.enabled(self.domain.name))
     self.assertFalse(domain_toggle.enabled(self.second_domain.name))
     self.assertTrue(domain_toggle.enabled_for_request(self.request))
     self.assertFalse(domain_toggle.enabled_for_request(self.second_request))
Ejemplo n.º 5
0
 def test_email_domain_namespace(self):
     email_domain_toggle = StaticToggle(
         'email_domain_namespace_toggle',
         'A test toggle',
         TAG_CUSTOM,
         [NAMESPACE_EMAIL_DOMAIN]
     )
     email_domain_toggle.set('somedomain.com', True, namespace=NAMESPACE_EMAIL_DOMAIN)
     self.assertTrue(email_domain_toggle.enabled(self.user.username))
     self.assertFalse(email_domain_toggle.enabled(self.second_user.username))
     self.assertTrue(email_domain_toggle.enabled_for_request(self.request))
     self.assertFalse(email_domain_toggle.enabled_for_request(self.second_request))
Ejemplo n.º 6
0
from unittest import mock

from corehq.apps.linked_domain.local_accessors import get_enabled_toggles
from corehq.apps.linked_domain.tests.test_linked_apps import BaseLinkedDomainTest
from corehq.apps.linked_domain.updates import update_toggles
from corehq.toggles import NAMESPACE_DOMAIN, StaticToggle, TAG_INTERNAL
from corehq.toggles.shortcuts import set_toggle

TEST_TOGGLE = StaticToggle(
    'test_toggle',
    'This is for tests',
    TAG_INTERNAL,
    [NAMESPACE_DOMAIN],
)


@mock.patch('corehq.toggles.all_toggles_by_name',
            mock.Mock(return_value={'TEST_TOGGLE': TEST_TOGGLE}))
class TestUpdateToggles(BaseLinkedDomainTest):
    def tearDown(self):
        super(TestUpdateToggles, self).tearDown()
        set_toggle('test_toggle', self.domain_link.master_domain, False,
                   NAMESPACE_DOMAIN)
        set_toggle('test_toggle', self.domain_link.linked_domain, False,
                   NAMESPACE_DOMAIN)

    def test_get_enabled_toggles(self):
        set_toggle('test_toggle', self.domain_link.master_domain, True,
                   NAMESPACE_DOMAIN)
        enabled_toggles = get_enabled_toggles(self.domain_link.master_domain)
        self.assertEqual(['test_toggle'], enabled_toggles)
Ejemplo n.º 7
0
from corehq.toggles import (
    NAMESPACE_DOMAIN,
    NAMESPACE_OTHER,
    NAMESPACE_USER,
    TAG_CUSTOM,
    DynamicallyPredictablyRandomToggle,
    StaticToggle,
)

DASHBOARD_ICDS_REPORT = StaticToggle(
    'dashboard_icds_reports',
    'ICDS: Enable access to the dashboard reports for ICDS',
    TAG_CUSTOM,
    [NAMESPACE_DOMAIN],
)

ICDS_DASHBOARD_SHOW_MOBILE_APK = DynamicallyPredictablyRandomToggle(
    'icds_dashboard_show_mobile_apk',
    'Show a "Mobile APK" download link on the ICDS Dashboard',
    TAG_CUSTOM,
    [NAMESPACE_USER],
)

ICDS_DASHBOARD_TEMPORARY_DOWNTIME = StaticToggle(
    'icds_dashboard_temporary_downtime',
    'ICDS: Temporarily disable the ICDS dashboard by showing a downtime page. '
    'This can be cicurmvented by adding "?bypass-downtime=True" to the end of the url.',
    TAG_CUSTOM,
    [NAMESPACE_DOMAIN]
)