mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 11:19:44 -04:00
Connect to s3 buckets created by notifications-api
This commit is contained in:
@@ -15,6 +15,8 @@ from app.s3_client.s3_letter_upload_client import (
|
||||
upload_letter_to_s3,
|
||||
)
|
||||
|
||||
pytest.skip(reason="Skipping letter-related features", allow_module_level=True)
|
||||
|
||||
|
||||
def test_backup_original_letter_to_s3(mocker, notify_admin):
|
||||
s3_mock = mocker.patch('app.s3_client.s3_letter_upload_client.utils_s3upload')
|
||||
|
||||
@@ -14,11 +14,28 @@ def vcap_services():
|
||||
'uri': 'redis://xxx:6379'
|
||||
}
|
||||
}],
|
||||
'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'
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_extract_cloudfoundry_config_populates_other_vars(os_environ, vcap_services):
|
||||
os.environ['DEPLOY_ENV'] = 'test'
|
||||
os.environ['VCAP_SERVICES'] = json.dumps(vcap_services)
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['REDIS_URL'] == 'rediss://xxx:6379'
|
||||
assert os.environ['CSV_UPLOAD_BUCKET_NAME'] == 'csv-upload-bucket'
|
||||
assert os.environ['CONTACT_LIST_BUCKET_NAME'] == 'contact-list-bucket'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
@@ -9,7 +8,7 @@ from app import config
|
||||
|
||||
|
||||
def cf_conf():
|
||||
os.environ['API_HOST_NAME'] = 'cf'
|
||||
os.environ['REDIS_URL'] = 'rediss://xxx:6379'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -29,16 +28,8 @@ def reload_config(os_environ):
|
||||
|
||||
|
||||
def test_load_cloudfoundry_config_if_available(reload_config):
|
||||
os.environ['API_HOST_NAME'] = 'env'
|
||||
os.environ['REDIS_URL'] = 'some uri'
|
||||
os.environ['VCAP_APPLICATION'] = 'some json blob'
|
||||
os.environ['VCAP_SERVICES'] = json.dumps({
|
||||
'aws-elasticache-redis': [{
|
||||
'credentials': {
|
||||
'uri': 'redis://xxx:6379'
|
||||
}
|
||||
}],
|
||||
})
|
||||
os.environ['VCAP_SERVICES'] = 'some json blob'
|
||||
|
||||
with mock.patch('app.cloudfoundry_config.extract_cloudfoundry_config', side_effect=cf_conf):
|
||||
# reload config so that its module level code (ie: all of it) is re-instantiated
|
||||
@@ -49,9 +40,8 @@ def test_load_cloudfoundry_config_if_available(reload_config):
|
||||
|
||||
|
||||
def test_load_config_if_cloudfoundry_not_available(reload_config):
|
||||
os.environ['API_HOST_NAME'] = 'env'
|
||||
|
||||
os.environ.pop('VCAP_APPLICATION', None)
|
||||
os.environ['REDIS_URL'] = 'redis://xxx:6379'
|
||||
os.environ.pop('VCAP_SERVICES', None)
|
||||
|
||||
with mock.patch('app.cloudfoundry_config.extract_cloudfoundry_config') as cf_config:
|
||||
# reload config so that its module level code (ie: all of it) is re-instantiated
|
||||
@@ -59,5 +49,5 @@ def test_load_config_if_cloudfoundry_not_available(reload_config):
|
||||
|
||||
assert not cf_config.called
|
||||
|
||||
assert os.environ['API_HOST_NAME'] == 'env'
|
||||
assert config.Config.API_HOST_NAME == 'env'
|
||||
assert os.environ['REDIS_URL'] == 'redis://xxx:6379'
|
||||
assert config.Config.REDIS_URL == 'redis://xxx:6379'
|
||||
|
||||
Reference in New Issue
Block a user