mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Better bucket name pending possible change to uuid for service primary
key. Also small bugfix around file name and original file name
This commit is contained in:
@@ -126,16 +126,20 @@ def test_create_job_should_call_api(app_,
|
||||
job_data,
|
||||
mock_create_job):
|
||||
|
||||
service_id = job_data['service']
|
||||
template_id = job_data['template']
|
||||
upload_id = job_data['id']
|
||||
file_name = job_data['original_file_name']
|
||||
service_id = service_one['id']
|
||||
job_id = job_data['id']
|
||||
file_name = job_data['file_name']
|
||||
|
||||
# TODO - template id should come from form but is not wired in yet.
|
||||
# that will be done in another story
|
||||
template_id = 1
|
||||
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
url = url_for('main.check_sms', service_id=service_id, upload_id=upload_id, file_name=file_name)
|
||||
url = url_for('main.check_sms', service_id=service_one['id'], upload_id=job_id, file_name=file_name)
|
||||
response = client.post(url, data=job_data, follow_redirects=True)
|
||||
|
||||
assert response.status_code == 200
|
||||
mock_create_job.assert_called_with(service_id, template_id, file_name)
|
||||
assert job_data['bucket_name'] == "service-{}-{}-notify".format(service_id, job_id)
|
||||
|
||||
@@ -425,15 +425,9 @@ def mock_check_verify_code_code_expired(mocker):
|
||||
def job_data(mocker):
|
||||
import uuid
|
||||
job_id = uuid.uuid4()
|
||||
original_file_name = 'thisisatest.csv'
|
||||
bucket_name = 'service-2-notify'
|
||||
file_name = '{}.csv'.format(job_id)
|
||||
file_name = 'thisisatest.csv'
|
||||
data = {
|
||||
'id': str(job_id),
|
||||
'service': 1,
|
||||
'template': 1,
|
||||
'original_file_name': original_file_name,
|
||||
'bucket_name': bucket_name,
|
||||
'file_name': file_name,
|
||||
}
|
||||
return data
|
||||
@@ -442,5 +436,10 @@ def job_data(mocker):
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_create_job(mocker, job_data):
|
||||
def _create(service_id, template_id, file_name):
|
||||
job_data['service'] = service_id
|
||||
job_data['template'] = template_id
|
||||
job_data['bucket_name'] = 'service-{}-{}-notify'.format(service_id, job_data['id'])
|
||||
job_data['original_file_name'] = file_name
|
||||
job_data['file_name'] = '{}.csv'.format(job_data['id'])
|
||||
return job_data
|
||||
return mocker.patch('app.job_api_client.create_job', side_effect=_create)
|
||||
|
||||
Reference in New Issue
Block a user