mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
test to make sure provider details history is bumped
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from app.models import ProviderDetails
|
||||
from app.models import ProviderDetails, ProviderDetailsHistory
|
||||
from app import clients
|
||||
from app.dao.provider_details_dao import (
|
||||
get_provider_details,
|
||||
get_provider_details_by_notification_type
|
||||
get_provider_details_by_notification_type,
|
||||
dao_update_provider_details
|
||||
)
|
||||
|
||||
|
||||
@@ -42,3 +43,29 @@ def test_should_not_error_if_any_provider_in_code_not_in_database(restore_provid
|
||||
ProviderDetails.query.filter_by(identifier='mmg').delete()
|
||||
|
||||
assert clients.get_sms_client('mmg')
|
||||
|
||||
|
||||
def test_update_adds_history(restore_provider_details):
|
||||
ses = ProviderDetails.query.filter(ProviderDetails.identifier == 'ses').one()
|
||||
ses_history = ProviderDetailsHistory.query.filter(ProviderDetailsHistory.id == ses.id).one()
|
||||
|
||||
assert ses.version == 1
|
||||
assert ses_history.version == 1
|
||||
|
||||
ses.active = False
|
||||
|
||||
dao_update_provider_details(ses)
|
||||
|
||||
assert not ses.active
|
||||
|
||||
ses_history = ProviderDetailsHistory.query.filter(
|
||||
ProviderDetailsHistory.id == ses.id
|
||||
).order_by(
|
||||
ProviderDetailsHistory.version
|
||||
).all()
|
||||
|
||||
assert ses_history[0].active
|
||||
assert ses_history[0].version == 1
|
||||
|
||||
assert not ses_history[1].active
|
||||
assert ses_history[1].version == 2
|
||||
|
||||
@@ -5,6 +5,7 @@ from app.models import ProviderDetails
|
||||
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
def test_get_provider_details_in_type_and_identifier_order(client, notify_db):
|
||||
response = client.get(
|
||||
'/provider-details',
|
||||
|
||||
Reference in New Issue
Block a user