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 {
|
|
|
|
|
'postgres': [{
|
2016-12-08 12:12:45 +00:00
|
|
|
'credentials': {
|
|
|
|
|
'uri': 'postgres uri'
|
|
|
|
|
}
|
2022-04-12 14:40:09 +01:00
|
|
|
}],
|
2022-04-12 14:48:08 +01:00
|
|
|
'redis': [{
|
|
|
|
|
'credentials': {
|
|
|
|
|
'uri': 'redis uri'
|
|
|
|
|
}
|
|
|
|
|
}],
|
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):
|
|
|
|
|
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'
|