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:
Leo Hemsted
2017-07-11 15:41:44 +01:00
parent 2fde4b2c80
commit 7f883f1355
4 changed files with 11 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ def extract_notify_config(notify_config):
os.environ['SECRET_KEY'] = notify_config['credentials']['secret_key']
os.environ['DANGEROUS_SALT'] = notify_config['credentials']['dangerous_salt']
os.environ['PERFORMANCE_PLATFORM_TOKEN'] = notify_config['credentials'].get('performance_platform_token', '')
os.environ['SMS_INBOUND_WHITELIST'] = notify_config['credentials']['allow_ip_inbound_sms']
os.environ['SMS_INBOUND_WHITELIST'] = json.dumps(notify_config['credentials']['allow_ip_inbound_sms'])
def extract_notify_aws_config(aws_config):

View File

@@ -1,5 +1,6 @@
from datetime import timedelta
import os
import json
from celery.schedules import crontab
from kombu import Exchange, Queue
@@ -262,7 +263,7 @@ class Config(object):
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
SMS_INBOUND_WHITELIST = os.environ.get('SMS_INBOUND_WHITELIST', [])
SMS_INBOUND_WHITELIST = json.loads(os.environ.get('SMS_INBOUND_WHITELIST', '[]'))
######################