mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
remove unused old file
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
from flask import current_app
|
|
||||||
|
|
||||||
from app.dao.users_dao import get_user_by_id
|
|
||||||
|
|
||||||
|
|
||||||
def provider_is_inactive(new_provider):
|
|
||||||
if not new_provider.active:
|
|
||||||
current_app.logger.warning('Cancelling switch to {} as they are inactive'.format(
|
|
||||||
new_provider.identifier,
|
|
||||||
))
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def provider_is_primary(current_provider, new_provider, identifier):
|
|
||||||
if current_provider.identifier == identifier:
|
|
||||||
current_app.logger.warning('Provider {} is already activated'.format(current_provider.display_name))
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def switch_providers(current_provider, new_provider):
|
|
||||||
# Automatic update so set as notify user
|
|
||||||
notify_user = get_user_by_id(current_app.config['NOTIFY_USER_ID'])
|
|
||||||
current_provider.created_by_id = new_provider.created_by_id = notify_user.id
|
|
||||||
|
|
||||||
# Swap priority to change primary provider
|
|
||||||
if new_provider.priority > current_provider.priority:
|
|
||||||
new_provider.priority, current_provider.priority = current_provider.priority, new_provider.priority
|
|
||||||
|
|
||||||
# Increase other provider priority if equal
|
|
||||||
elif new_provider.priority == current_provider.priority:
|
|
||||||
current_provider.priority += 10
|
|
||||||
|
|
||||||
_print_provider_switch_logs(current_provider, new_provider)
|
|
||||||
return current_provider, new_provider
|
|
||||||
|
|
||||||
|
|
||||||
def _print_provider_switch_logs(current_provider, new_provider):
|
|
||||||
current_app.logger.warning('Switching provider from {} to {}'.format(
|
|
||||||
current_provider.identifier,
|
|
||||||
new_provider.identifier
|
|
||||||
))
|
|
||||||
|
|
||||||
current_app.logger.warning('Provider {} now updated with priority of {}'.format(
|
|
||||||
current_provider.identifier,
|
|
||||||
current_provider.priority
|
|
||||||
))
|
|
||||||
|
|
||||||
current_app.logger.warning('Provider {} now updated with priority of {}'.format(
|
|
||||||
new_provider.identifier,
|
|
||||||
new_provider.priority
|
|
||||||
))
|
|
||||||
@@ -105,7 +105,6 @@ def test_provider_details_schema_returns_user_details(
|
|||||||
):
|
):
|
||||||
from app.schemas import provider_details_schema
|
from app.schemas import provider_details_schema
|
||||||
current_sms_provider = get_provider_details_by_identifier('mmg')
|
current_sms_provider = get_provider_details_by_identifier('mmg')
|
||||||
mocker.patch('app.provider_details.switch_providers.get_user_by_id', return_value=sample_user)
|
|
||||||
current_sms_provider.created_by = sample_user
|
current_sms_provider.created_by = sample_user
|
||||||
data = provider_details_schema.dump(current_sms_provider).data
|
data = provider_details_schema.dump(current_sms_provider).data
|
||||||
|
|
||||||
@@ -118,7 +117,6 @@ def test_provider_details_history_schema_returns_user_details(
|
|||||||
restore_provider_details,
|
restore_provider_details,
|
||||||
):
|
):
|
||||||
from app.schemas import provider_details_schema
|
from app.schemas import provider_details_schema
|
||||||
mocker.patch('app.provider_details.switch_providers.get_user_by_id', return_value=sample_user)
|
|
||||||
current_sms_provider = get_provider_details_by_identifier('mmg')
|
current_sms_provider = get_provider_details_by_identifier('mmg')
|
||||||
current_sms_provider.created_by_id = sample_user.id
|
current_sms_provider.created_by_id = sample_user.id
|
||||||
data = provider_details_schema.dump(current_sms_provider).data
|
data = provider_details_schema.dump(current_sms_provider).data
|
||||||
|
|||||||
Reference in New Issue
Block a user