def test_extract_settings_case_sensitive(self):
        """Test :func:`.extract_settings` can correctly extract ``DB_`` prefixed settings from a class (case sensitive)"""
        extracted = helpers.extract_settings('DB_',
                                             self.ExSettingsClass,
                                             _case_sensitive=True)

        self._compare_settings(self.ExSettingsClass, extracted, uppercase=True)
    def test_extract_settings_case_sensitive_fail(self):
        """Test :func:`.extract_settings` returns empty dict for ``db_`` prefix from a class (case sensitive)"""
        extracted = helpers.extract_settings('db_',
                                             self.ExSettingsClass,
                                             _case_sensitive=True)

        self.assertTrue(isinstance(extracted, dict))
        self.assertEqual(len(extracted.keys()), 0)
    def test_extract_settings_class_instance_case_sensitive(self):
        """
        Test :func:`.extract_settings` can correctly extract ``DB_`` prefixed settings from a class instance/object (case sensitive)
        """
        inst = self.ExSettingsInst()
        extracted = helpers.extract_settings('db_', inst, _case_sensitive=True)

        self._compare_settings(inst, extracted, orig_uppercase=False)
    def test_extract_settings_class_instance_case_sensitive_fail(self):
        """
        Test :func:`.extract_settings` returns empty dict for ``DB_`` prefixed settings from a class instance
        (case sensitive)
        """
        inst = self.ExSettingsInst()
        extracted = helpers.extract_settings('DB_', inst, _case_sensitive=True)

        self.assertTrue(isinstance(extracted, dict))
        self.assertEqual(len(extracted.keys()), 0)
    def test_extract_settings_modules(self):
        """Test :func:`.extract_settings` can correctly extract ``DB_`` prefixed settings from a python module"""
        from privex.helpers import settings as ex_settings

        keys_ex = [k for k in ex_settings.__dict__.keys() if k[:6] == 'REDIS_']

        extracted = helpers.extract_settings('REDIS_', ex_settings)
        self.assertEqual(extracted['db'], ex_settings.REDIS_DB)
        self.assertEqual(extracted['port'], ex_settings.REDIS_PORT)
        self.assertEqual(extracted['host'], ex_settings.REDIS_HOST)

        self.assertEqual(len(extracted.keys()), len(keys_ex))
    def test_extract_settings_class(self):
        """Test :func:`.extract_settings` can correctly extract ``DB_`` prefixed settings from a class"""
        extracted = helpers.extract_settings('DB_', self.ExSettingsClass)

        self._compare_settings(self.ExSettingsClass, extracted)
 def test_extract_settings_dict(self):
     """Test :func:`.extract_settings` can correctly extract ``DB_`` prefixed settings from a ``dict``"""
     ex_settings = self.ex_settings
     extracted = helpers.extract_settings('DB_', ex_settings)
     self._compare_settings(ex_settings, extracted)