mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-31 19:58:46 -04:00
Refactor code to add updated_at
This commit is contained in:
@@ -4,9 +4,9 @@ from sqlalchemy.exc import IntegrityError
|
||||
from app.dao.inbound_numbers_dao import (
|
||||
dao_get_inbound_numbers,
|
||||
dao_get_available_inbound_numbers,
|
||||
dao_get_inbound_number_for_service,
|
||||
dao_get_inbound_number,
|
||||
dao_set_inbound_number_to_service,
|
||||
dao_set_inbound_number_active_flag_for_service
|
||||
dao_set_inbound_number_active_flag
|
||||
)
|
||||
from app.models import InboundNumber
|
||||
|
||||
@@ -56,15 +56,12 @@ def test_after_setting_service_id_that_inbound_number_is_unavailable(
|
||||
assert len(res) == 0
|
||||
|
||||
|
||||
def test_get_inbound_number_for_service(notify_db, notify_db_session, sample_inbound_numbers):
|
||||
service = create_service(service_name='test service')
|
||||
inbound_number = create_inbound_number(number='4')
|
||||
def test_get_inbound_number(notify_db, notify_db_session):
|
||||
inbound_number = create_inbound_number(number='1')
|
||||
|
||||
dao_set_inbound_number_to_service(service.id, inbound_number)
|
||||
res = dao_get_inbound_number(inbound_number.id)
|
||||
|
||||
res = dao_get_inbound_number_for_service(service.id)
|
||||
|
||||
assert res.service_id == service.id
|
||||
assert res.id == inbound_number.id
|
||||
|
||||
|
||||
def test_setting_a_service_twice_will_raise_an_error(notify_db, notify_db_session):
|
||||
@@ -78,9 +75,6 @@ def test_setting_a_service_twice_will_raise_an_error(notify_db, notify_db_sessio
|
||||
with pytest.raises(IntegrityError) as e:
|
||||
dao_set_inbound_number_to_service(service.id, numbers[1])
|
||||
|
||||
res = dao_get_inbound_number_for_service(service.id)
|
||||
|
||||
assert res.service_id == service.id
|
||||
assert 'duplicate key value violates unique constraint' in str(e.value)
|
||||
|
||||
|
||||
@@ -89,8 +83,8 @@ def test_set_inbound_number_active_flag(notify_db, notify_db_session, sample_ser
|
||||
inbound_number = create_inbound_number(number='1')
|
||||
dao_set_inbound_number_to_service(sample_service.id, inbound_number)
|
||||
|
||||
dao_set_inbound_number_active_flag_for_service(sample_service.id, active=active)
|
||||
dao_set_inbound_number_active_flag(inbound_number.id, active=active)
|
||||
|
||||
inbound_number = dao_get_inbound_number_for_service(sample_service.id)
|
||||
inbound_number = dao_get_inbound_number(inbound_number.id)
|
||||
|
||||
assert inbound_number.active is active
|
||||
|
||||
@@ -19,7 +19,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
|
||||
from tests.app.db import create_notification, create_service, create_inbound_number
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mobile_number', [
|
||||
@@ -218,3 +218,12 @@ def test_email_notification_serializes_with_subject(client, sample_email_templat
|
||||
def test_letter_notification_serializes_with_subject(client, sample_letter_template):
|
||||
res = sample_letter_template.serialize()
|
||||
assert res['subject'] == 'Template subject'
|
||||
|
||||
|
||||
def test_inbound_number_serializes_with_service(client, notify_db_session):
|
||||
service = create_service()
|
||||
inbound_number = create_inbound_number(number='1', service_id=service.id)
|
||||
serialized_inbound_number = inbound_number.serialize()
|
||||
assert serialized_inbound_number.get('id') == str(inbound_number.id)
|
||||
assert serialized_inbound_number.get('service').get('id') == str(inbound_number.service.id)
|
||||
assert serialized_inbound_number.get('service').get('name') == inbound_number.service.name
|
||||
|
||||
Reference in New Issue
Block a user