Example #1
0
import os

from utils.environment import get_environment_variable

# ------- GENERAL ------- #
SERVICE_ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = os.path.abspath(os.path.join(SERVICE_ROOT, os.pardir))
SERVICE_NAME = get_environment_variable("SERVICE_NAME", "broker-api")
COMMIT = get_environment_variable("COMMIT", "COMMIT")

# ------- DB INFO ------- #
DB_USER = get_environment_variable("DB_USER")
DB_PASSWORD = get_environment_variable("DB_PASSWORD")
DB_ADDRESS = get_environment_variable("DB_ADDRESS")
DB_PORT = get_environment_variable("DB_PORT", "3306")
DB_DATABASE = get_environment_variable("DB_DATABASE", "broker")

# ------- SCHEMA ------- #
SCHEMA_FILE = os.path.join(SERVICE_ROOT, "documentation", "schema.yaml")
Example #2
0
import os

from utils.environment import get_environment_variable

SERVICE_ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = os.path.abspath(os.path.join(SERVICE_ROOT, os.pardir))
SCHEMA_FILE = os.path.join(SERVICE_ROOT, "api", "schemas", "api_schema.yaml")
SERVICE_NAME = get_environment_variable("SERVICE_NAME",
                                        "registration-validator-api")
COMMIT = get_environment_variable("COMMIT", None)

DB_USER = get_environment_variable("DB_USER")
DB_PASSWORD = get_environment_variable("DB_PASSWORD")
DB_ADDRESS = get_environment_variable("DB_ADDRESS")
DB_DATABASE = get_environment_variable("DB_DATABASE", "registration_validator")
Example #3
0
 def test_invalid_env_var(self):
     with self.assertRaises(expected_exception=AttributeError):
         get_environment_variable(variable_name=self.invalid_env_var)
Example #4
0
 def test_invalid_env_var_with_default(self):
     default_value = str(uuid4())
     retrieved_value = get_environment_variable(
         variable_name=self.invalid_env_var, default_value=default_value)
     self.assertEqual(default_value, retrieved_value)
Example #5
0
 def test_valid_env_var(self):
     retrieved_value = get_environment_variable(
         variable_name=self.valid_env_var)
     self.assertEqual(self.test_value, retrieved_value)