2022-04-12 16:48:38 +01:00
|
|
|
import json
|
2016-12-08 16:50:37 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2018-01-09 14:18:32 +00:00
|
|
|
from app.cloudfoundry_config import extract_cloudfoundry_config
|
2016-12-08 16:50:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2022-04-13 14:45:29 +01:00
|
|
|
def vcap_services():
|
2022-04-12 16:48:38 +01:00
|
|
|
return {
|
2022-08-05 00:25:03 -07:00
|
|
|
'aws-elasticache-redis': [{
|
2022-04-12 16:48:38 +01:00
|
|
|
'credentials': {
|
2022-09-09 17:02:48 -07:00
|
|
|
'uri': 'redis://xxx:6379'
|
2022-04-12 16:48:38 +01:00
|
|
|
}
|
|
|
|
|
}],
|
2022-09-19 11:19:38 -04:00
|
|
|
's3': [
|
|
|
|
|
{
|
|
|
|
|
'name': 'notifications-api-csv-upload-bucket-test',
|
|
|
|
|
'credentials': {
|
2022-09-22 12:33:55 -04:00
|
|
|
'access_key_id': 'csv-access',
|
|
|
|
|
'bucket': 'csv-upload-bucket',
|
2022-09-26 10:25:03 -04:00
|
|
|
'region': 'us-gov-west-1',
|
2022-09-22 12:33:55 -04:00
|
|
|
'secret_access_key': 'csv-secret'
|
2022-09-19 11:19:38 -04:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'name': 'notifications-api-contact-list-bucket-test',
|
|
|
|
|
'credentials': {
|
2022-09-22 12:33:55 -04:00
|
|
|
'access_key_id': 'contact-list-access',
|
|
|
|
|
'bucket': 'contact-list-bucket',
|
2022-09-26 10:25:03 -04:00
|
|
|
'region': 'us-gov-west-1',
|
2022-09-22 12:33:55 -04:00
|
|
|
'secret_access_key': 'contact-list-secret'
|
2022-09-19 11:19:38 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2022-04-12 16:48:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-13 14:45:29 +01:00
|
|
|
def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_services):
|
2022-09-19 11:19:38 -04:00
|
|
|
os.environ['DEPLOY_ENV'] = 'test'
|
2022-04-13 14:45:29 +01:00
|
|
|
os.environ['VCAP_SERVICES'] = json.dumps(vcap_services)
|
2017-01-09 19:14:04 +00:00
|
|
|
extract_cloudfoundry_config()
|
|
|
|
|
|
2022-09-09 17:02:48 -07:00
|
|
|
assert os.environ['REDIS_URL'] == 'rediss://xxx:6379'
|
2022-09-19 11:19:38 -04:00
|
|
|
assert os.environ['CSV_UPLOAD_BUCKET_NAME'] == 'csv-upload-bucket'
|
|
|
|
|
assert os.environ['CONTACT_LIST_BUCKET_NAME'] == 'contact-list-bucket'
|