2016-12-08 12:12:45 +00:00
|
|
|
import json
|
2021-03-10 13:55:06 +00:00
|
|
|
import os
|
2016-12-08 12:12:45 +00:00
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2022-04-13 14:46:52 +01:00
|
|
|
from app.cloudfoundry_config import extract_cloudfoundry_config
|
2016-12-08 12:12:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2022-04-13 14:46:52 +01:00
|
|
|
def vcap_services():
|
2022-04-12 14:40:09 +01:00
|
|
|
return {
|
2022-07-05 11:27:15 -07:00
|
|
|
'aws-rds': [{
|
2016-12-08 12:12:45 +00:00
|
|
|
'credentials': {
|
|
|
|
|
'uri': 'postgres uri'
|
|
|
|
|
}
|
2022-04-12 14:40:09 +01:00
|
|
|
}],
|
2022-07-05 11:27:15 -07:00
|
|
|
'aws-elasticache-redis': [{
|
2022-04-12 14:48:08 +01:00
|
|
|
'credentials': {
|
|
|
|
|
'uri': 'redis uri'
|
|
|
|
|
}
|
|
|
|
|
}],
|
2022-09-16 16:26:02 -04:00
|
|
|
's3': [
|
|
|
|
|
{
|
|
|
|
|
'name': 'notifications-api-csv-upload-bucket-test',
|
|
|
|
|
'credentials': {
|
|
|
|
|
'bucket': 'csv-upload-bucket'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'name': 'notifications-api-contact-list-bucket-test',
|
|
|
|
|
'credentials': {
|
|
|
|
|
'bucket': 'contact-list-bucket'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2018-01-04 16:55:49 +00:00
|
|
|
'user-provided': []
|
2016-12-08 12:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-13 14:46:52 +01:00
|
|
|
def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_services):
|
2022-09-16 16:26:02 -04:00
|
|
|
os.environ['DEPLOY_ENV'] = 'test'
|
2022-04-13 14:46:52 +01:00
|
|
|
os.environ['VCAP_SERVICES'] = json.dumps(vcap_services)
|
2016-12-08 12:12:45 +00:00
|
|
|
extract_cloudfoundry_config()
|
|
|
|
|
|
2021-04-29 13:49:37 +01:00
|
|
|
assert os.environ['SQLALCHEMY_DATABASE_URI'] == 'postgresql uri'
|
2022-04-12 14:48:08 +01:00
|
|
|
assert os.environ['REDIS_URL'] == 'redis uri'
|
2022-09-16 16:26:02 -04:00
|
|
|
assert os.environ['CSV_UPLOAD_BUCKET_NAME'] == 'csv-upload-bucket'
|
|
|
|
|
assert os.environ['CONTACT_LIST_BUCKET_NAME'] == 'contact-list-bucket'
|