示例#1
0
    def test_groups(self):
        """
        Verifies that settings can be  assigned to a group different from the default
        Also, verifies that local enabled takes precedence over the group enabled status
        """
        settings = Settings(group='my_group')

        self.assertFalse(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        ##################
        config(reset=True)

        settings = Settings(group='my_group', enabled=True)

        self.assertTrue(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        ##################
        config(reset=True)

        settings = Settings(group='my_group', enabled=False)

        self.assertFalse(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertFalse(settings)

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])
示例#2
0
    def test_can_create_settings_instance(self):
        """
        Verifies that Settings instance and especially its enabled property work as intended
        """
        settings = Settings()

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        #############################################

        settings = Settings(enabled=True)

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        #############################################

        settings = Settings(enabled=False)

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])
示例#3
0
    def test_can_create_settings_instance(self):
        """
        Verifies that Settings instance and especially its enabled property work as intended
        """
        settings = Settings()

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        #############################################

        settings = Settings(enabled=True)

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        #############################################

        settings = Settings(enabled=False)

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertEqual(settings.group, 'default')

        settings.enabled = True

        self.assertTrue(settings.enabled)
        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = False

        self.assertFalse(settings.enabled)
        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])
示例#4
0
    def test_groups(self):
        """
        Verifies that settings can be  assigned to a group different from the default
        Also, verifies that local enabled takes precedence over the group enabled status
        """
        settings = Settings(group='my_group')

        self.assertFalse(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        ##################
        config(reset=True)

        settings = Settings(group='my_group', enabled=True)

        self.assertTrue(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        ##################
        config(reset=True)

        settings = Settings(group='my_group', enabled=False)

        self.assertFalse(settings)
        self.assertEqual(settings.group, 'my_group')

        config({'groups': {'set': {'my_group': True}}})

        self.assertFalse(settings)

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS['enabled'])
示例#5
0
    def test_groups(self):
        """
        Verifies that settings can be  assigned to a group different from the default
        Also, verifies that local enabled takes precedence over the group enabled status
        """
        settings = Settings(group="my_group")

        self.assertFalse(settings)
        self.assertEqual(settings.group, "my_group")

        config({"groups": {"set": {"my_group": True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])

        ##################
        config(reset=True)

        settings = Settings(group="my_group", enabled=True)

        self.assertTrue(settings)
        self.assertEqual(settings.group, "my_group")

        config({"groups": {"set": {"my_group": True}}})

        self.assertTrue(settings)

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])

        ##################
        config(reset=True)

        settings = Settings(group="my_group", enabled=False)

        self.assertFalse(settings)
        self.assertEqual(settings.group, "my_group")

        config({"groups": {"set": {"my_group": True}}})

        self.assertFalse(settings)

        settings.enabled = True

        self.assertTrue(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])

        settings.enabled = False

        self.assertFalse(settings)
        self.assertTrue(_GLOBAL_SETTINGS["enabled"])