remove unused provider dao functions

This commit is contained in:
Leo Hemsted
2019-11-11 14:47:20 +00:00
parent fa7e0a1e84
commit 8fa7cde593
3 changed files with 19 additions and 102 deletions

View File

@@ -11,7 +11,7 @@ from requests import HTTPError
import app
from app import mmg_client, firetext_client
from app.dao import (provider_details_dao, notifications_dao)
from app.dao.provider_details_dao import dao_switch_sms_provider_to_provider_with_identifier
from app.dao.provider_details_dao import get_provider_details_by_identifier
from app.delivery import send_to_providers
from app.exceptions import NotificationTechnicalFailureException
from app.models import (
@@ -567,64 +567,60 @@ def test_should_set_notification_billable_units_if_sending_to_provider_fails(
def test_should_send_sms_to_international_providers(
restore_provider_details,
sample_sms_template_with_html,
sample_template,
sample_user,
mocker
):
mocker.patch('app.provider_details.switch_providers.get_user_by_id', return_value=sample_user)
mocker.patch('app.mmg_client.send_sms')
mocker.patch('app.firetext_client.send_sms')
dao_switch_sms_provider_to_provider_with_identifier('firetext')
# set firetext to active
get_provider_details_by_identifier('firetext').priority = 100
get_provider_details_by_identifier('mmg').priority = 0
db_notification_uk = create_notification(
template=sample_sms_template_with_html,
notification_uk = create_notification(
template=sample_template,
to_field="+447234123999",
personalisation={"name": "Jo"},
status='created',
international=False,
reply_to_text=sample_sms_template_with_html.service.get_default_sms_sender()
reply_to_text=sample_template.service.get_default_sms_sender()
)
db_notification_international = create_notification(
template=sample_sms_template_with_html,
notification_international = create_notification(
template=sample_template,
to_field="+6011-17224412",
personalisation={"name": "Jo"},
status='created',
international=True,
reply_to_text=sample_sms_template_with_html.service.get_default_sms_sender()
reply_to_text=sample_template.service.get_default_sms_sender()
)
mocker.patch('app.mmg_client.send_sms')
mocker.patch('app.firetext_client.send_sms')
send_to_providers.send_sms_to_provider(
db_notification_uk
notification_uk
)
firetext_client.send_sms.assert_called_once_with(
to="447234123999",
content=ANY,
reference=str(db_notification_uk.id),
reference=str(notification_uk.id),
sender=current_app.config['FROM_NUMBER']
)
send_to_providers.send_sms_to_provider(
db_notification_international
notification_international
)
mmg_client.send_sms.assert_called_once_with(
to="601117224412",
content=ANY,
reference=str(db_notification_international.id),
reference=str(notification_international.id),
sender=current_app.config['FROM_NUMBER']
)
notification_uk = Notification.query.filter_by(id=db_notification_uk.id).one()
notification_int = Notification.query.filter_by(id=db_notification_international.id).one()
assert notification_uk.status == 'sending'
assert notification_uk.sent_by == 'firetext'
assert notification_int.status == 'sent'
assert notification_int.sent_by == 'mmg'
assert notification_international.status == 'sent'
assert notification_international.sent_by == 'mmg'
@pytest.mark.parametrize('sms_sender, expected_sender, prefix_sms, expected_content', [