mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Merge pull request #1266 from alphagov/use-reply-to-from-new-table
Use reply to email address from new table
This commit is contained in:
@@ -23,7 +23,8 @@ from app.models import (
|
||||
BRANDING_BOTH,
|
||||
BRANDING_ORG_BANNER)
|
||||
|
||||
from tests.app.db import create_service, create_template, create_notification, create_inbound_number
|
||||
from tests.app.db import create_service, create_template, create_notification, create_inbound_number, \
|
||||
create_reply_to_email
|
||||
|
||||
|
||||
def test_should_return_highest_priority_active_provider(restore_provider_details):
|
||||
@@ -386,7 +387,7 @@ def test_send_email_should_use_service_reply_to_email(
|
||||
mocker.patch('app.delivery.send_to_providers.create_initial_notification_statistic_tasks')
|
||||
|
||||
db_notification = create_notification(template=sample_email_template)
|
||||
sample_service.reply_to_email_address = 'foo@bar.com'
|
||||
create_reply_to_email(service=sample_service, email_address='foo@bar.com')
|
||||
|
||||
send_to_providers.send_email_to_provider(
|
||||
db_notification,
|
||||
@@ -398,7 +399,7 @@ def test_send_email_should_use_service_reply_to_email(
|
||||
ANY,
|
||||
body=ANY,
|
||||
html_body=ANY,
|
||||
reply_to_address=sample_service.reply_to_email_address
|
||||
reply_to_address=sample_service.get_default_reply_to_email_address()
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -213,19 +213,19 @@ def test_get_service_by_id_should_404_if_no_service(notify_api, notify_db):
|
||||
assert json_resp['message'] == 'No result found'
|
||||
|
||||
|
||||
def test_get_service_by_id_and_user(notify_api, service_factory, sample_user):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
service = service_factory.get('new.service', sample_user)
|
||||
auth_header = create_authorization_header()
|
||||
resp = client.get(
|
||||
'/service/{}?user_id={}'.format(service.id, sample_user.id),
|
||||
headers=[auth_header]
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == service.name
|
||||
assert json_resp['data']['id'] == str(service.id)
|
||||
def test_get_service_by_id_and_user(client, sample_service, sample_user):
|
||||
sample_service.reply_to_email = 'something@service.com'
|
||||
create_reply_to_email(service=sample_service, email_address='new@service.com')
|
||||
auth_header = create_authorization_header()
|
||||
resp = client.get(
|
||||
'/service/{}?user_id={}'.format(sample_service.id, sample_user.id),
|
||||
headers=[auth_header]
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == sample_service.name
|
||||
assert json_resp['data']['id'] == str(sample_service.id)
|
||||
assert json_resp['data']['reply_to_email_address'] == 'new@service.com'
|
||||
|
||||
|
||||
def test_get_service_by_id_should_404_if_no_service_for_user(notify_api, sample_user):
|
||||
@@ -2161,7 +2161,6 @@ def test_get_email_reply_to_addresses_when_there_are_no_reply_to_email_addresses
|
||||
def test_get_email_reply_to_addresses_with_one_email_address(client, notify_db, notify_db_session):
|
||||
service = create_service(notify_db=notify_db, notify_db_session=notify_db_session)
|
||||
reply_to = create_reply_to_email(service, 'test@mail.com')
|
||||
service.reply_to_email_address = 'test@mail.com'
|
||||
|
||||
response = client.get('/service/{}/email-reply-to'.format(service.id),
|
||||
headers=[create_authorization_header()])
|
||||
|
||||
@@ -21,7 +21,7 @@ from tests.app.conftest import (
|
||||
sample_template as create_sample_template,
|
||||
sample_notification_with_job as create_sample_notification_with_job
|
||||
)
|
||||
from tests.app.db import create_notification, create_service, create_inbound_number
|
||||
from tests.app.db import create_notification, create_service, create_inbound_number, create_reply_to_email
|
||||
from tests.conftest import set_config
|
||||
|
||||
|
||||
@@ -256,3 +256,9 @@ def test_inbound_number_returns_from_number_config(client, notify_db_session):
|
||||
service = create_service(sms_sender=None)
|
||||
|
||||
assert service.get_inbound_number() == 'test'
|
||||
|
||||
|
||||
def test_service_get_default_reply_to_email_address(sample_service):
|
||||
create_reply_to_email(service=sample_service, email_address="default@email.com")
|
||||
|
||||
assert sample_service.get_default_reply_to_email_address() == 'default@email.com'
|
||||
|
||||
Reference in New Issue
Block a user