Added environ tests
This commit is contained in:
parent
e4de5667b4
commit
482b6a633b
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# Setup test environment variables
|
# Setup test environment variables
|
||||||
os.environ["ENVIRON"] = "test"
|
if os.environ.get("ENVIRON") is None:
|
||||||
|
os.environ["ENVIRON"] = "test"
|
||||||
|
28
tests/general/test_env.py
Normal file
28
tests/general/test_env.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from os import environ
|
||||||
|
from warnings import warn
|
||||||
|
|
||||||
|
# Tests environment variables used within the projects domain are
|
||||||
|
# set in the correct environment
|
||||||
|
|
||||||
|
VARS = ['ENVIRON', 'APPSECRET', 'FILESTORE']
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
var = environ.get('ENVIRON')
|
||||||
|
assert var is not None
|
||||||
|
assert (var == "test" or var == "prod")
|
Loading…
Reference in New Issue
Block a user