Refactor tests to use cleaner fixture and be more verbose in tests

This commit is contained in:
Imdad Ahad
2017-02-27 13:18:42 +00:00
parent 17b6c13c46
commit d805985a4e
2 changed files with 44 additions and 34 deletions

View File

@@ -19,7 +19,7 @@ from app.dao.provider_details_dao import (
)
def set_primary_sms_provider(identifier='mmg'):
def set_primary_sms_provider(restore_provider_details, identifier='mmg'):
primary_provider = get_provider_details_by_identifier(identifier)
secondary_provider = get_alternative_sms_provider(identifier)
@@ -153,22 +153,28 @@ def test_toggle_sms_provider_switches_provider(
):
dao_toggle_sms_provider(current_sms_provider.identifier)
new_provider = get_current_provider('sms')
assert new_provider.identifier != current_sms_provider.identifier
assert new_provider.priority < current_sms_provider.priority
old_starting_provider = get_provider_details_by_identifier(current_sms_provider.identifier)
assert new_provider.identifier != old_starting_provider.identifier
assert new_provider.priority < old_starting_provider.priority
def test_toggle_sms_provider_switches_when_provider_priorities_are_equal(
restore_provider_details,
current_sms_provider
restore_provider_details
):
new_provider = get_alternative_sms_provider(current_sms_provider.identifier)
current_sms_provider.priority = new_provider.priority
dao_update_provider_details(current_sms_provider)
current_provider = get_current_provider('sms')
new_provider = get_alternative_sms_provider(current_provider.identifier)
dao_toggle_sms_provider(current_sms_provider.identifier)
current_provider.priority = new_provider.priority
dao_update_provider_details(current_provider)
assert new_provider.identifier != current_sms_provider.identifier
assert new_provider.priority < current_sms_provider.priority
dao_toggle_sms_provider(current_provider.identifier)
old_starting_provider = get_provider_details_by_identifier(current_provider.identifier)
assert new_provider.identifier != old_starting_provider.identifier
assert new_provider.priority < old_starting_provider.priority
def test_toggle_sms_provider_updates_provider_history(