mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
A little clean up
This commit is contained in:
@@ -57,8 +57,7 @@ from tests.app.db import (
|
||||
create_service,
|
||||
create_api_key,
|
||||
create_inbound_number,
|
||||
create_letter_contact,
|
||||
create_inbound_sms,
|
||||
create_letter_contact
|
||||
)
|
||||
|
||||
|
||||
@@ -649,16 +648,6 @@ def sample_email_notification(notify_db, notify_db_session):
|
||||
return notification
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_statsd_inc(mocker):
|
||||
return mocker.patch('app.statsd_client.incr')
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_statsd_timing(mocker):
|
||||
return mocker.patch('app.statsd_client.timing')
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_notification_history(
|
||||
notify_db,
|
||||
@@ -1048,18 +1037,13 @@ def sample_provider_rate(notify_db, notify_db_session, valid_from=None, rate=Non
|
||||
@pytest.fixture
|
||||
def sample_inbound_numbers(notify_db, notify_db_session, sample_service):
|
||||
service = create_service(service_name='sample service 2')
|
||||
inbound_numbers = []
|
||||
inbound_numbers = list()
|
||||
inbound_numbers.append(create_inbound_number(number='1', provider='mmg'))
|
||||
inbound_numbers.append(create_inbound_number(number='2', provider='mmg', active=False, service_id=service.id))
|
||||
inbound_numbers.append(create_inbound_number(number='3', provider='firetext', service_id=sample_service.id))
|
||||
return inbound_numbers
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_inbound_sms(notify_db, notify_db_session, sample_service):
|
||||
return create_inbound_sms(sample_service)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def restore_provider_details(notify_db, notify_db_session):
|
||||
"""
|
||||
|
||||
@@ -90,25 +90,28 @@ def test_should_not_delete_inbound_sms_before_seven_days(sample_service):
|
||||
assert len(InboundSms.query.all()) == 2
|
||||
|
||||
|
||||
def test_get_inbound_sms_by_id_returns(sample_inbound_sms):
|
||||
inbound_from_db = dao_get_inbound_sms_by_id(sample_inbound_sms.service.id, sample_inbound_sms.id)
|
||||
def test_get_inbound_sms_by_id_returns(sample_service):
|
||||
inbound_sms = create_inbound_sms(service=sample_service)
|
||||
inbound_from_db = dao_get_inbound_sms_by_id(inbound_sms.service.id, inbound_sms.id)
|
||||
|
||||
assert sample_inbound_sms == inbound_from_db
|
||||
assert inbound_sms == inbound_from_db
|
||||
|
||||
|
||||
def test_dao_get_paginated_inbound_sms_for_service(sample_inbound_sms):
|
||||
inbound_from_db = dao_get_paginated_inbound_sms_for_service(sample_inbound_sms.service.id)
|
||||
def test_dao_get_paginated_inbound_sms_for_service(sample_service):
|
||||
inbound_sms = create_inbound_sms(service=sample_service)
|
||||
inbound_from_db = dao_get_paginated_inbound_sms_for_service(inbound_sms.service.id)
|
||||
|
||||
assert sample_inbound_sms == inbound_from_db[0]
|
||||
assert inbound_sms == inbound_from_db[0]
|
||||
|
||||
|
||||
def test_dao_get_paginated_inbound_sms_for_service_return_only_for_service(sample_inbound_sms):
|
||||
def test_dao_get_paginated_inbound_sms_for_service_return_only_for_service(sample_service):
|
||||
inbound_sms = create_inbound_sms(service=sample_service)
|
||||
another_service = create_service(service_name='another service')
|
||||
another_inbound_sms = create_inbound_sms(another_service)
|
||||
|
||||
inbound_from_db = dao_get_paginated_inbound_sms_for_service(sample_inbound_sms.service.id)
|
||||
inbound_from_db = dao_get_paginated_inbound_sms_for_service(inbound_sms.service.id)
|
||||
|
||||
assert sample_inbound_sms in inbound_from_db
|
||||
assert inbound_sms in inbound_from_db
|
||||
assert another_inbound_sms not in inbound_from_db
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ def create_template(
|
||||
template_name=None,
|
||||
subject='Template subject',
|
||||
content='Dear Sir/Madam, Hello. Yours Truly, The Government.',
|
||||
template_id=None,
|
||||
reply_to=None
|
||||
):
|
||||
data = {
|
||||
|
||||
@@ -97,15 +97,16 @@ def test_get_next_inbound_sms_will_get_correct_inbound_sms_list(client, sample_s
|
||||
_external=True) == json_response['links']['next']
|
||||
|
||||
|
||||
def test_get_next_inbound_sms_at_end_will_return_empty_inbound_sms_list(client, sample_inbound_sms, mocker):
|
||||
def test_get_next_inbound_sms_at_end_will_return_empty_inbound_sms_list(client, sample_service, mocker):
|
||||
inbound_sms = create_inbound_sms(service=sample_service)
|
||||
mocker.patch.dict(
|
||||
"app.v2.inbound_sms.get_inbound_sms.current_app.config",
|
||||
{"API_PAGE_SIZE": 1}
|
||||
)
|
||||
|
||||
auth_header = create_authorization_header(service_id=sample_inbound_sms.service.id)
|
||||
auth_header = create_authorization_header(service_id=inbound_sms.service.id)
|
||||
response = client.get(
|
||||
path=url_for('v2_inbound_sms.get_inbound_sms', older_than=sample_inbound_sms.id),
|
||||
path=url_for('v2_inbound_sms.get_inbound_sms', older_than=inbound_sms.id),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user