2024-01-29 22:07:36 +00:00
|
|
|
from os import environ
|
|
|
|
from warnings import warn
|
2024-01-30 19:30:02 +00:00
|
|
|
from tests import old_env
|
2024-01-29 22:07:36 +00:00
|
|
|
|
|
|
|
# Tests environment variables used within the projects domain are
|
|
|
|
# set in the correct environment
|
|
|
|
|
|
|
|
VARS = ['ENVIRON', 'APPSECRET', 'FILESTORE']
|
|
|
|
|
2024-01-30 19:30:02 +00:00
|
|
|
ENV_STATES = ['test', 'prod']
|
|
|
|
|
2024-01-29 22:07:36 +00:00
|
|
|
|
|
|
|
def test_env_vars():
|
|
|
|
""" Test that required environment variables are set
|
|
|
|
ahead of runtime
|
|
|
|
"""
|
|
|
|
for var in VARS:
|
|
|
|
env = environ.get(var)
|
|
|
|
|
|
|
|
# Check to see what variable we are comparing
|
|
|
|
if env is None:
|
|
|
|
warn(f"Variable {var} is not set!")
|
|
|
|
|
|
|
|
|
|
|
|
def test_environment_var_state():
|
|
|
|
""" Tests that the 'ENVIRON' Environment variable
|
|
|
|
is in a correct state
|
|
|
|
"""
|
2024-01-30 19:30:02 +00:00
|
|
|
var = old_env
|
2024-01-29 22:07:36 +00:00
|
|
|
assert var is not None
|
2024-01-30 19:30:02 +00:00
|
|
|
assert (var in ENV_STATES)
|