mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
don't store non-strings to os.environ
in tests, we were replacing os.environ with a basic dict so that we didn't overwrite the contents of the real environment during tests. However, os.environ doesn't accept non-str values, so this commit changes the fixture so that it asserts all values set are strings. We needed to change how we store ip whitelist stuff in the env because of this.
This commit is contained in:
@@ -204,4 +204,4 @@ def test_redis_config():
|
||||
def test_sms_inbound_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['SMS_INBOUND_WHITELIST'] == ['111.111.111.111', '100.100.100.100']
|
||||
assert os.environ['SMS_INBOUND_WHITELIST'] == json.dumps(['111.111.111.111', '100.100.100.100'])
|
||||
|
||||
@@ -90,7 +90,13 @@ def os_environ():
|
||||
"""
|
||||
# for use whenever you expect code to edit environment variables
|
||||
old_env = os.environ.copy()
|
||||
os.environ = {}
|
||||
|
||||
class EnvironDict(dict):
|
||||
def __setitem__(self, key, value):
|
||||
assert type(value) == str
|
||||
super().__setitem__(key, value)
|
||||
|
||||
os.environ = EnvironDict()
|
||||
yield
|
||||
os.environ = old_env
|
||||
|
||||
|
||||
Reference in New Issue
Block a user