mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge pull request #2639 from alphagov/remove-loadtesting-db-migration
remove loadtesting from the database
This commit is contained in:
@@ -16,10 +16,13 @@ from app.dao.jobs_dao import (
|
||||
dao_get_notification_outcomes_for_job,
|
||||
dao_set_scheduled_jobs_to_pending,
|
||||
dao_update_job,
|
||||
find_jobs_with_missing_rows,
|
||||
find_missing_row_for_job
|
||||
)
|
||||
from app.models import (
|
||||
Job,
|
||||
EMAIL_TYPE, SMS_TYPE, LETTER_TYPE
|
||||
EMAIL_TYPE, SMS_TYPE, LETTER_TYPE,
|
||||
JOB_STATUS_FINISHED
|
||||
)
|
||||
from tests.app.db import create_job, create_service, create_template, create_notification
|
||||
|
||||
@@ -409,3 +412,61 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_notifica
|
||||
result, errors = can_letter_job_be_cancelled(job)
|
||||
assert not result
|
||||
assert errors == "We are still processing these letters, please try again in a minute."
|
||||
|
||||
|
||||
def test_find_jobs_with_missing_rows(sample_email_template):
|
||||
job = create_job(template=sample_email_template, notification_count=5, job_status=JOB_STATUS_FINISHED)
|
||||
for i in range(0, 4):
|
||||
create_notification(job=job, job_row_number=i)
|
||||
|
||||
results = find_jobs_with_missing_rows()
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0] == (4, 4, job.id, job.service_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('status', ['pending', 'in progress', 'cancelled', 'scheduled'])
|
||||
def test_find_jobs_with_missing_rows_doesnt_return_jobs_that_are_not_finished(
|
||||
sample_email_template, status
|
||||
):
|
||||
job = create_job(template=sample_email_template, notification_count=5, job_status=status)
|
||||
for i in range(0, 4):
|
||||
create_notification(job=job, job_row_number=i)
|
||||
|
||||
results = find_jobs_with_missing_rows()
|
||||
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
def test_find_missing_row_for_job(sample_email_template):
|
||||
job = create_job(template=sample_email_template, notification_count=5, job_status=JOB_STATUS_FINISHED)
|
||||
create_notification(job=job, job_row_number=0)
|
||||
create_notification(job=job, job_row_number=1)
|
||||
create_notification(job=job, job_row_number=3)
|
||||
create_notification(job=job, job_row_number=4)
|
||||
|
||||
results = find_missing_row_for_job(job.id, 5)
|
||||
assert len(results) == 1
|
||||
assert results[0].missing_row == 2
|
||||
|
||||
|
||||
def test_find_missing_row_for_job_more_than_one_missing_row(sample_email_template):
|
||||
job = create_job(template=sample_email_template, notification_count=5, job_status=JOB_STATUS_FINISHED)
|
||||
create_notification(job=job, job_row_number=0)
|
||||
create_notification(job=job, job_row_number=1)
|
||||
create_notification(job=job, job_row_number=4)
|
||||
|
||||
results = find_missing_row_for_job(job.id, 5)
|
||||
assert len(results) == 2
|
||||
assert results[0].missing_row == 2
|
||||
assert results[1].missing_row == 3
|
||||
|
||||
|
||||
def test_find_missing_row_for_job_return_none_when_row_isnt_missing(sample_email_template):
|
||||
job = create_job(template=sample_email_template, notification_count=5, job_status=JOB_STATUS_FINISHED)
|
||||
for i in range(0, 5):
|
||||
create_notification(job=job, job_row_number=i)
|
||||
|
||||
results = find_missing_row_for_job(job.id, 5)
|
||||
print(results)
|
||||
assert len(results) == 0
|
||||
|
||||
@@ -38,7 +38,7 @@ def set_primary_sms_provider(identifier):
|
||||
|
||||
def test_can_get_sms_non_international_providers(restore_provider_details):
|
||||
sms_providers = get_provider_details_by_notification_type('sms')
|
||||
assert len(sms_providers) == 3
|
||||
assert len(sms_providers) == 2
|
||||
assert all('sms' == prov.notification_type for prov in sms_providers)
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ def test_dao_get_provider_stats(notify_db_session):
|
||||
|
||||
result = dao_get_provider_stats()
|
||||
|
||||
assert len(result) == 5
|
||||
assert len(result) == 4
|
||||
|
||||
assert result[0].identifier == 'ses'
|
||||
assert result[0].display_name == 'AWS SES'
|
||||
@@ -326,9 +326,6 @@ def test_dao_get_provider_stats(notify_db_session):
|
||||
assert result[2].active is True
|
||||
assert result[2].current_month_billable_sms == 5
|
||||
|
||||
assert result[3].identifier == 'loadtesting'
|
||||
assert result[3].identifier == 'dvla'
|
||||
assert result[3].current_month_billable_sms == 0
|
||||
|
||||
assert result[4].identifier == 'dvla'
|
||||
assert result[4].current_month_billable_sms == 0
|
||||
assert result[4].supports_international is False
|
||||
assert result[3].supports_international is False
|
||||
|
||||
@@ -15,13 +15,12 @@ def test_get_provider_details_in_type_and_identifier_order(client, notify_db):
|
||||
)
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))['provider_details']
|
||||
assert len(json_resp) == 5
|
||||
assert len(json_resp) == 4
|
||||
|
||||
assert json_resp[0]['identifier'] == 'ses'
|
||||
assert json_resp[1]['identifier'] == 'mmg'
|
||||
assert json_resp[2]['identifier'] == 'firetext'
|
||||
assert json_resp[3]['identifier'] == 'loadtesting'
|
||||
assert json_resp[4]['identifier'] == 'dvla'
|
||||
assert json_resp[3]['identifier'] == 'dvla'
|
||||
|
||||
|
||||
def test_get_provider_details_by_id(client, notify_db):
|
||||
@@ -55,7 +54,7 @@ def test_get_provider_contains_correct_fields(client, sample_service, sample_tem
|
||||
"active", "updated_at", "supports_international",
|
||||
"current_month_billable_sms"
|
||||
}
|
||||
assert len(json_resp) == 5
|
||||
assert len(json_resp) == 4
|
||||
assert allowed_keys == set(json_resp[0].keys())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user