mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
ensure no tests share the same name (using flake8's checker)
This commit is contained in:
@@ -477,7 +477,7 @@ def test_should_not_update_status_by_reference_if_from_country_with_no_delivery_
|
||||
assert notification.status == NOTIFICATION_SENT
|
||||
|
||||
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_no_delivery_receipts(sample_template):
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_carrier_delivery_receipts(sample_template):
|
||||
notification = create_notification(
|
||||
sample_template,
|
||||
status=NOTIFICATION_SENT,
|
||||
@@ -491,7 +491,7 @@ def test_should_not_update_status_by_id_if_sent_to_country_with_no_delivery_rece
|
||||
assert notification.status == NOTIFICATION_SENT
|
||||
|
||||
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_no_delivery_receipts(sample_template):
|
||||
def test_should_not_update_status_by_id_if_sent_to_country_with_delivery_receipts(sample_template):
|
||||
notification = create_notification(
|
||||
sample_template,
|
||||
status=NOTIFICATION_SENT,
|
||||
@@ -2071,7 +2071,7 @@ def test_dao_get_last_notification_added_for_job_id_no_notifications(sample_temp
|
||||
assert dao_get_last_notification_added_for_job_id(job.id) is None
|
||||
|
||||
|
||||
def test_dao_get_last_notification_added_for_job_id_no_notifications(sample_template, fake_uuid):
|
||||
def test_dao_get_last_notification_added_for_job_id_no_job(sample_template, fake_uuid):
|
||||
|
||||
assert dao_get_last_notification_added_for_job_id(fake_uuid) is None
|
||||
|
||||
|
||||
@@ -93,15 +93,17 @@ def test_dao_allocate_number_for_service(notify_db_session):
|
||||
assert updated_inbound_number.service_id == service.id
|
||||
|
||||
|
||||
def test_dao_allocate_number_for_service(notify_db_session, sample_service):
|
||||
def test_dao_allocate_number_for_service_raises_if_inbound_number_already_taken(notify_db_session, sample_service):
|
||||
number = '078945612'
|
||||
inbound_number = create_inbound_number(number=number, service_id=sample_service.id)
|
||||
service = create_service(service_name="Service needs an inbound number")
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(Exception) as exc:
|
||||
dao_allocate_number_for_service(service_id=service.id, inbound_number_id=inbound_number.id)
|
||||
assert 'is not available' in str(exc.value)
|
||||
|
||||
|
||||
def test_dao_allocate_number_for_service(notify_db_session, sample_service):
|
||||
def test_dao_allocate_number_for_service_raises_if_invalid_inbound_number(notify_db_session, fake_uuid):
|
||||
service = create_service(service_name="Service needs an inbound number")
|
||||
with pytest.raises(Exception):
|
||||
dao_allocate_number_for_service(service_id=service.id, inbound_number_id=uuid.uuid4())
|
||||
with pytest.raises(Exception) as exc:
|
||||
dao_allocate_number_for_service(service_id=service.id, inbound_number_id=fake_uuid)
|
||||
assert 'is not available' in str(exc.value)
|
||||
|
||||
@@ -426,7 +426,7 @@ def test_should_get_jobs_seven_days_old_filters_type(notify_db, notify_db_sessio
|
||||
assert job_to_remain.id not in [job.id for job in jobs]
|
||||
|
||||
|
||||
def test_dao_get_job_statistics_for_job(notify_db, notify_db_session, sample_job):
|
||||
def test_dao_get_job_statistics_for_job_calculates_stats(notify_db, notify_db_session, sample_job):
|
||||
notification = create_notification(notify_db=notify_db, notify_db_session=notify_db_session, job=sample_job)
|
||||
notification_delivered = create_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
job=sample_job, status='delivered')
|
||||
@@ -438,16 +438,19 @@ def test_dao_get_job_statistics_for_job(notify_db, notify_db_session, sample_job
|
||||
create_or_update_job_sending_statistics(notification_failed)
|
||||
update_job_stats_outcome_count(notification_delivered)
|
||||
update_job_stats_outcome_count(notification_failed)
|
||||
|
||||
result = dao_get_job_statistics_for_job(sample_job.service_id, sample_job.id)
|
||||
|
||||
assert_job_stat(job=sample_job, result=result, sent=3, delivered=1, failed=1)
|
||||
|
||||
|
||||
def test_dao_get_job_statistics_for_job(notify_db, notify_db_session, sample_service):
|
||||
def test_dao_get_job_statistics_for_job_separates_jobs(notify_db, notify_db_session, sample_service):
|
||||
job_1, job_2 = stats_set_up(notify_db, notify_db_session, sample_service)
|
||||
result = dao_get_job_statistics_for_job(sample_service.id, job_1.id)
|
||||
assert_job_stat(job=job_1, result=result, sent=2, delivered=1, failed=0)
|
||||
|
||||
result = dao_get_job_statistics_for_job(sample_service.id, job_1.id)
|
||||
result_2 = dao_get_job_statistics_for_job(sample_service.id, job_2.id)
|
||||
|
||||
assert_job_stat(job=job_1, result=result, sent=2, delivered=1, failed=0)
|
||||
assert_job_stat(job=job_2, result=result_2, sent=1, delivered=0, failed=1)
|
||||
|
||||
|
||||
|
||||
@@ -57,20 +57,6 @@ def test_get_job_with_unknown_id_returns404(notify_api, sample_template, fake_uu
|
||||
}
|
||||
|
||||
|
||||
def test_get_job_by_id(notify_api, sample_job):
|
||||
job_id = str(sample_job.id)
|
||||
service_id = sample_job.service.id
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
path = '/service/{}/job/{}'.format(service_id, job_id)
|
||||
auth_header = create_authorization_header()
|
||||
response = client.get(path, headers=[auth_header])
|
||||
assert response.status_code == 200
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
assert resp_json['data']['id'] == job_id
|
||||
assert resp_json['data']['created_by']['name'] == 'Test User'
|
||||
|
||||
|
||||
def test_cancel_job(notify_api, sample_scheduled_job):
|
||||
job_id = str(sample_scheduled_job.id)
|
||||
service_id = sample_scheduled_job.service.id
|
||||
|
||||
@@ -626,6 +626,12 @@ def test_post_email_notification_with_valid_reply_to_id_returns_201(client, samp
|
||||
assert resp_json['id'] == str(notification.id)
|
||||
assert mocked.called
|
||||
|
||||
email_reply_to = NotificationEmailReplyTo.query.one()
|
||||
|
||||
assert email_reply_to.notification_id == notification.id
|
||||
assert email_reply_to.service_email_reply_to_id == reply_to_email.id
|
||||
assert notification.reply_to_text == reply_to_email.email_address
|
||||
|
||||
|
||||
def test_post_email_notification_with_invalid_reply_to_id_returns_400(client, sample_email_template, mocker, fake_uuid):
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
@@ -646,33 +652,6 @@ def test_post_email_notification_with_invalid_reply_to_id_returns_400(client, sa
|
||||
assert 'BadRequestError' in resp_json['errors'][0]['error']
|
||||
|
||||
|
||||
def test_post_email_notification_with_valid_reply_to_id_returns_201(client, sample_email_template, mocker):
|
||||
reply_to_email = create_reply_to_email(sample_email_template.service, 'test@test.com')
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
data = {
|
||||
"email_address": sample_email_template.service.users[0].email_address,
|
||||
"template_id": sample_email_template.id,
|
||||
'email_reply_to_id': reply_to_email.id
|
||||
}
|
||||
auth_header = create_authorization_header(service_id=sample_email_template.service_id)
|
||||
response = client.post(
|
||||
path="v2/notifications/email",
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 201
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
assert validate(resp_json, post_email_response) == resp_json
|
||||
notification = Notification.query.first()
|
||||
assert resp_json['id'] == str(notification.id)
|
||||
assert mocked.called
|
||||
|
||||
email_reply_to = NotificationEmailReplyTo.query.one()
|
||||
|
||||
assert email_reply_to.notification_id == notification.id
|
||||
assert email_reply_to.service_email_reply_to_id == reply_to_email.id
|
||||
assert notification.reply_to_text == reply_to_email.email_address
|
||||
|
||||
|
||||
def test_persist_sender_to_notification_mapping_for_email(notify_db_session):
|
||||
service = create_service()
|
||||
template = create_template(service=service, template_type=EMAIL_TYPE)
|
||||
|
||||
Reference in New Issue
Block a user