Exemplo n.º 1
0
 def test_encrypt_conf(self):
     crypt = Crypt(path=self.BASE_DIR)
     crypt._loader.put_file(b"9IXx2F5d5Ob-h5xdCnFSUXhuFKLGRibvLfSbixpcfCw=",
                            "wb")
     config = get_conf(service=CONFIG_BASE, uppercase=True)
     crypt.delete_key()
     assert config.database_url == "http://database-url"
Exemplo n.º 2
0
 def test_encrypt_conf_deprecated_env(self):
     os.environ[CRYPT_FILE_KEY_ENVIRONMENT_LEGACY] = os.getenv(CRYPT_FILE_KEY_ENVIRONMENT)
     del os.environ[CRYPT_FILE_KEY_ENVIRONMENT]
     crypt = CryptFernet(path=self.BASE_DIR)
     crypt._loader.put_file(b"9IXx2F5d5Ob-h5xdCnFSUXhuFKLGRibvLfSbixpcfCw=", "wb")
     config = get_conf(service=CONFIG_BASE, uppercase=True, crypt=CryptFernet)
     crypt.delete_key()
     assert config.database_url == "http://database-url"
Exemplo n.º 3
0
 def __init__(self):
     self.config = get_conf(service=self.service, empty_init=True, uppercase=False)
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     self.service = get_service_name(service=self.service)
     self.config = get_conf(service=self.service, empty_init=True)
Exemplo n.º 5
0
 def test_without_params(self, mock_confile):
     with self.assertRaises(ServiceDoesNotExistException):
         get_conf()
Exemplo n.º 6
0
 def test_default_flask(self):
     config = get_conf(service=CONFIG_BASE, uppercase=True).to_flask()
     assert config.APP_NAME == "Python Microservice"
     assert config.SUBSERVICE1.test == "input"
Exemplo n.º 7
0
 def test_default(self):
     config = get_conf(service=CONFIG_BASE, uppercase=True)
     assert config.app_name == "Python Microservice"
     assert config.subservice1.test == "input"
Exemplo n.º 8
0
 def __init__(self, *args, **kwargs):
     self.path = os.path.dirname(kwargs.get("path", __file__))
     validate_conf()
     self.config = get_conf(path=self.path, service=CONFIG_BASE)
     self.init_services()
Exemplo n.º 9
0
 def test_encrypt_conf(self, mock_aws_decrypt, mock_init_boto):
     mock_aws_decrypt.return_value = "http://database-url"
     crypt = CryptResource()
     config = get_conf(service=CONFIG_BASE, uppercase=True, crypt=crypt)
     assert config.encrypted_key == "http://database-url"
Exemplo n.º 10
0
 def __init__(self, service=None):
     self.service = (service if service else SERVICE_BASE)
     self.config = get_conf(service=self.service,
                            empty_init=True,
                            memoize=False)
Exemplo n.º 11
0
 def __init__(self, service, *args, **kwargs):
     self.service = ".".join([service, self.service])
     self.config = get_conf(service=self.service,
                            empty_init=True,
                            memoize=kwargs.get("memoize", True))
Exemplo n.º 12
0
 def __init__(self, *args, **kwargs):
     self.config = get_conf(service=self.config_resource, empty_init=True, uppercase=False, *args, **kwargs)
Exemplo n.º 13
0
    def test_without_memoize(self, mock_confile):
        mock_confile.pyms = {}
        get_conf(service="pyms", memoize=False)
        get_conf(service="pyms", memoize=False)

        assert mock_confile.call_count == 2
Exemplo n.º 14
0
    def test_memoized(self, mock_confile):
        mock_confile.pyms = {}
        get_conf(service="pyms")
        get_conf(service="pyms")

        mock_confile.assert_called_once()
Exemplo n.º 15
0
    def test_default(self):
        config = get_conf(service="my-ms")

        assert config.APP_NAME == "Python Microservice"
        assert config.subservice1.test == "input"
Exemplo n.º 16
0
 def __init__(self, *args, **kwargs):
     self.service = kwargs.get("service",
                               os.environ.get(SERVICE_ENVIRONMENT, "ms"))
     self.path = os.path.dirname(kwargs.get("path", __file__))
     self.config = get_conf(service=self.service, memoize=self._singleton)
     self.init_services()