mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
Refactor job conftests to eliminate temp variables
These tests were assigning something to a variable, then immediately returning that variable. Why not just return the thing itself?
This commit is contained in:
@@ -779,7 +779,7 @@ def mock_check_verify_code_code_expired(mocker):
|
|||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_create_job(mocker, api_user_active):
|
def mock_create_job(mocker, api_user_active):
|
||||||
def _create(job_id, service_id, template_id, file_name, notification_count):
|
def _create(job_id, service_id, template_id, file_name, notification_count):
|
||||||
job_data = job_json(
|
return job_json(
|
||||||
service_id,
|
service_id,
|
||||||
api_user_active,
|
api_user_active,
|
||||||
job_id=job_id,
|
job_id=job_id,
|
||||||
@@ -787,7 +787,6 @@ def mock_create_job(mocker, api_user_active):
|
|||||||
bucket_name='service-{}-notify'.format(job_id),
|
bucket_name='service-{}-notify'.format(job_id),
|
||||||
original_file_name='{}.csv'.format(job_id),
|
original_file_name='{}.csv'.format(job_id),
|
||||||
notification_count=notification_count)
|
notification_count=notification_count)
|
||||||
return job_data
|
|
||||||
|
|
||||||
return mocker.patch('app.job_api_client.create_job', side_effect=_create)
|
return mocker.patch('app.job_api_client.create_job', side_effect=_create)
|
||||||
|
|
||||||
@@ -795,8 +794,7 @@ def mock_create_job(mocker, api_user_active):
|
|||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_get_job(mocker, api_user_active):
|
def mock_get_job(mocker, api_user_active):
|
||||||
def _get_job(service_id, job_id):
|
def _get_job(service_id, job_id):
|
||||||
job_data = job_json(service_id, api_user_active, job_id=job_id)
|
return {"data": job_json(service_id, api_user_active, job_id=job_id)}
|
||||||
return {"data": job_data}
|
|
||||||
|
|
||||||
return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)
|
return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)
|
||||||
|
|
||||||
@@ -804,17 +802,16 @@ def mock_get_job(mocker, api_user_active):
|
|||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_get_jobs(mocker, api_user_active):
|
def mock_get_jobs(mocker, api_user_active):
|
||||||
def _get_jobs(service_id, limit_days=None):
|
def _get_jobs(service_id, limit_days=None):
|
||||||
data = []
|
return {"data": [
|
||||||
for filename in [
|
job_json(service_id, api_user_active, original_file_name=filename)
|
||||||
"Test message",
|
for filename in (
|
||||||
"export 1/1/2016.xls",
|
"Test message",
|
||||||
"all email addresses.xlsx",
|
"export 1/1/2016.xls",
|
||||||
"applicants.ods",
|
"all email addresses.xlsx",
|
||||||
"thisisatest.csv",
|
"applicants.ods",
|
||||||
]:
|
"thisisatest.csv",
|
||||||
job_data = job_json(service_id, api_user_active, original_file_name=filename)
|
)
|
||||||
data.append(job_data)
|
]}
|
||||||
return {"data": data}
|
|
||||||
|
|
||||||
return mocker.patch('app.job_api_client.get_job', side_effect=_get_jobs)
|
return mocker.patch('app.job_api_client.get_job', side_effect=_get_jobs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user