Пример #1
0
    def test_get_idempotent(self):
        pconf.store.env.os.environ = TEST_ENV_VARS

        env_store = Env()
        result = env_store.get()

        self.assertEqual(result, TEST_ENV_VARS)
        self.assertIsInstance(result, dict)

        pconf.store.env.os.environ = TEST_ENV_BASE_VARS
        result = env_store.get()

        self.assertEqual(result, TEST_ENV_VARS)
        self.assertIsInstance(result, dict)
Пример #2
0
 def test_convert_underscore_and_separator(self):
     pconf.store.env.os.environ = TEST_ENV_VARS
     env_store = Env(separator=TEST_SEPARATOR,
                     convert_underscores=TEST_CONVERT_UNDERSCORES)
     result = env_store.get()
     self.assertEqual(result, TEST_ENV_CONVERTED_SEPARATED)
     self.assertIsInstance(result, dict)
Пример #3
0
    def test_separator(self):
        pconf.store.env.os.environ = TEST_ENV_VARS
        env_store = Env(separator=TEST_SEPARATOR)
        result = env_store.get()

        self.assertEqual(result, TEST_SEPARATED_VARS)
        self.assertIsInstance(result, dict)
Пример #4
0
    def test_match(self):
        pconf.store.env.os.environ = TEST_ENV_VARS
        env_store = Env(match=TEST_MATCH)
        result = env_store.get()

        self.assertEqual(result, TEST_ENV_MATCHED_VARS)
        self.assertIsInstance(result, dict)
Пример #5
0
    def test_whitelist(self):
        pconf.store.env.os.environ = TEST_ENV_VARS
        env_store = Env(whitelist=TEST_WHITELIST)
        result = env_store.get()

        self.assertEqual(result, TEST_ENV_WHITELIST_VARS)
        self.assertIsInstance(result, dict)
Пример #6
0
    def test_docker_secrets_invalid_postfix(self):
        pconf.store.env.os.environ = TEST_ENV_DOCKER_SECRETS_INVALID_POSTFIX

        env_store = Env(docker_secrets=TEST_DOCKER_SECRETS_INVALID_POSTFIX)
        result = env_store.get()

        self.assertEqual(result, {})
        self.assertIsInstance(result, dict)
Пример #7
0
    def test_whitelist_and_match(self):
        pconf.store.env.os.environ = TEST_ENV_VARS
        env_store = Env(match=TEST_MATCH, whitelist=TEST_WHITELIST)
        result = env_store.get()

        self.assertEqual(
            result, dict(TEST_ENV_MATCHED_VARS, **TEST_ENV_WHITELIST_VARS))
        self.assertIsInstance(result, dict)
Пример #8
0
    def test_get_all_vars(self):
        pconf.store.env.os.environ = TEST_ENV_VARS

        env_store = Env()
        result = env_store.get()

        self.assertEqual(result, TEST_ENV_VARS)
        self.assertIsInstance(result, dict)
Пример #9
0
    def test_docker_secrets_nonexistent_file(self, mock_open):
        simplefilter("ignore")
        pconf.store.env.os.environ = TEST_ENV_DOCKER_SECRETS

        env_store = Env(docker_secrets=TEST_DOCKER_SECRETS)
        result = env_store.get()

        self.assertEqual(result, {})
        self.assertIsInstance(result, dict)
Пример #10
0
    def test_docker_secrets(self):
        pconf.store.env.os.environ = TEST_ENV_DOCKER_SECRETS

        env_store = Env(docker_secrets=TEST_DOCKER_SECRETS)
        result = env_store.get()

        self.assertEqual(list(result.keys()),
                         list(TEST_DOCKER_SECRETS_RESULT.keys()))
        self.assertEqual(result, TEST_DOCKER_SECRETS_RESULT)
        self.assertIsInstance(result, dict)
Пример #11
0
    def test_parse_and_split_order(self):
        pconf.store.env.os.environ = TEST_ENV_VARS
        try:
            env_store = Env(separator=TEST_SEPARATOR,
                            parse_values=TEST_PARSE_VALUES)
        except AttributeError:
            self.fail("Parsing environment variables raised AttributeError")
        result = env_store.get()

        self.assertEqual(result, TEST_SEPARATED_VARS)
        self.assertIsInstance(result, dict)
Пример #12
0
 def test_convert_underscore_replacement(self):
     pconf.store.env.os.environ = TEST_ENV_VARS
     env_store = Env(convert_underscores=TEST_CONVERT_UNDERSCORES)
     result = env_store.get()
     self.assertEqual(result, TEST_ENV_CONVERTED)
     self.assertIsInstance(result, dict)
Пример #13
0
 def test_lowercase_and_separator(self):
     pconf.store.env.os.environ = TEST_ENV_UPPERCASE
     env_store = Env(separator=TEST_SEPARATOR, to_lower=TEST_TO_LOWER)
     result = env_store.get()
     self.assertEqual(result, TEST_SEPARATED_VARS)
     self.assertIsInstance(result, dict)
Пример #14
0
 def test_lowercase_conversion(self):
     pconf.store.env.os.environ = TEST_ENV_UPPERCASE
     env_store = Env(to_lower=TEST_TO_LOWER)
     result = env_store.get()
     self.assertEqual(result, TEST_ENV_VARS)
     self.assertIsInstance(result, dict)
Пример #15
0
 def test_parse_values(self):
     pconf.store.env.os.environ = TEST_ENV_TYPED_VARS
     env_store = Env(parse_values=TEST_PARSE_VALUES)
     result = env_store.get()
     self.assertEqual(result, TEST_ENV_TYPED_VARS_PARSED)
     self.assertIsInstance(result, dict)