From c36b64c91bdb4458aec9a8ab1fc39cb44713b2e5 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Mon, 22 Feb 2016 14:56:09 +0000 Subject: [PATCH] Added notification count to jobs. --- app/models.py | 1 + migrations/versions/0020_add_job_metadata.py | 26 ++++++++++++++++++++ tests/app/conftest.py | 3 ++- tests/app/dao/test_jobs_dao.py | 3 ++- tests/app/job/test_job_rest.py | 4 ++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 migrations/versions/0020_add_job_metadata.py diff --git a/app/models.py b/app/models.py index ce810287a..84726164a 100644 --- a/app/models.py +++ b/app/models.py @@ -159,6 +159,7 @@ class Job(db.Model): nullable=True, onupdate=datetime.datetime.now) status = db.Column(db.Enum(*JOB_STATUS_TYPES, name='job_status_types'), nullable=False, default='pending') + notification_count = db.Column(db.Integer, nullable=False) VERIFY_CODE_TYPES = ['email', 'sms'] diff --git a/migrations/versions/0020_add_job_metadata.py b/migrations/versions/0020_add_job_metadata.py new file mode 100644 index 000000000..e4d74a282 --- /dev/null +++ b/migrations/versions/0020_add_job_metadata.py @@ -0,0 +1,26 @@ +"""empty message + +Revision ID: 0020_add_job_metadata +Revises: 0019_unique_servicename +Create Date: 2016-02-22 12:33:02.360780 + +""" + +# revision identifiers, used by Alembic. +revision = '0020_add_job_metadata' +down_revision = '0019_unique_servicename' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('jobs', sa.Column('notification_count', sa.Integer(), nullable=False)) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('jobs', 'notification_count') + ### end Alembic commands ### diff --git a/tests/app/conftest.py b/tests/app/conftest.py index 3f12fc1a0..64afdb28a 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -159,7 +159,8 @@ def sample_job(notify_db, 'template_id': template.id, 'bucket_name': bucket_name, 'file_name': file_name, - 'original_file_name': 'some.csv' + 'original_file_name': 'some.csv', + 'notification_count': 1 } job = Job(**data) save_job(job) diff --git a/tests/app/dao/test_jobs_dao.py b/tests/app/dao/test_jobs_dao.py index 06f515fd6..be9fa7b9d 100644 --- a/tests/app/dao/test_jobs_dao.py +++ b/tests/app/dao/test_jobs_dao.py @@ -24,7 +24,8 @@ def test_save_job(notify_db, notify_db_session, sample_template): 'template_id': sample_template.id, 'bucket_name': bucket_name, 'file_name': file_name, - 'original_file_name': 'some.csv' + 'original_file_name': 'some.csv', + 'notification_count': 1 } job = Job(**data) diff --git a/tests/app/job/test_job_rest.py b/tests/app/job/test_job_rest.py index ccbe0ba3b..66aa83ef1 100644 --- a/tests/app/job/test_job_rest.py +++ b/tests/app/job/test_job_rest.py @@ -90,6 +90,7 @@ def test_create_job(notify_api, notify_db, notify_db_session, sample_template): 'original_file_name': original_file_name, 'bucket_name': bucket_name, 'file_name': file_name, + 'notification_count': 1 } with notify_api.test_request_context(): @@ -142,7 +143,8 @@ def test_get_update_job_status(notify_api, 'bucket_name': sample_job.bucket_name, 'file_name': sample_job.file_name, 'original_file_name': sample_job.original_file_name, - 'status': 'in progress' + 'status': 'in progress', + 'notification_count': 1 } with notify_api.test_request_context():