Add convenience fields to job to make processing

easier.
This commit is contained in:
Adam Shimali
2016-01-16 10:14:48 +00:00
parent 4d8a023f11
commit f3b6769193
5 changed files with 49 additions and 17 deletions

View File

@@ -78,10 +78,15 @@ def sample_job(notify_db,
if template is None:
template = sample_template(notify_db, notify_db_session,
service=service)
job_id = uuid.uuid4()
bucket_name = 'service-{}-notify'.format(service.id)
file_name = '{}.csv'.format(job_id)
data = {
'id': uuid.uuid4(),
'service_id': service.id,
'template_id': template.id,
'bucket_name': bucket_name,
'file_name': file_name,
'original_file_name': 'some.csv'
}
job = Job(**data)

View File

@@ -13,11 +13,16 @@ from app.models import Job
def test_save_job(notify_db, notify_db_session, sample_template):
assert Job.query.count() == 0
job_id = uuid.uuid4()
bucket_name = 'service-{}-notify'.format(sample_template.service.id)
file_name = '{}.csv'.format(job_id)
data = {
'id': job_id,
'service_id': sample_template.service_id,
'service_id': sample_template.service.id,
'template_id': sample_template.id,
'bucket_name': bucket_name,
'file_name': file_name,
'original_file_name': 'some.csv'
}
@@ -29,21 +34,9 @@ def test_save_job(notify_db, notify_db_session, sample_template):
assert job == job_from_db
def test_get_job_by_id(notify_db, notify_db_session, sample_template):
assert Job.query.count() == 0
job_id = uuid.uuid4()
data = {
'id': job_id,
'service_id': sample_template.service_id,
'template_id': sample_template.id,
'original_file_name': 'some.csv'
}
job = Job(**data)
save_job(job)
job_from_db = get_job_by_id(job_id)
assert job == job_from_db
def test_get_job_by_id(notify_db, notify_db_session, sample_job):
job_from_db = get_job_by_id(sample_job.id)
assert sample_job == job_from_db
def test_get_jobs_for_service(notify_db, notify_db_session, sample_job):

View File

@@ -69,11 +69,15 @@ def test_post_job(notify_api, notify_db, notify_db_session, sample_template):
template_id = sample_template.id
service_id = sample_template.service.id
original_file_name = 'thisisatest.csv'
bucket_name = 'service-{}-notify'.format(service_id)
file_name = '{}.csv'.format(job_id)
data = {
'id': str(job_id),
'service': service_id,
'template': template_id,
'original_file_name': original_file_name
'original_file_name': original_file_name,
'bucket_name': bucket_name,
'file_name': file_name,
}
with notify_api.test_request_context():
with notify_api.test_client() as client: