Refactor to switch properly when providers have equal priority with test

This commit is contained in:
Imdad Ahad
2017-01-23 13:36:04 +00:00
parent 0a277b26b6
commit e1d1769345
4 changed files with 29 additions and 19 deletions

View File

@@ -21,14 +21,12 @@ def update_provider_priorities(current_provider, new_provider):
# 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
_print_provider_switch_logs(current_provider, new_provider)
return [current_provider, new_provider]
# Incease 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]
_print_provider_switch_logs(current_provider, new_provider)
def _print_provider_switch_logs(current_provider, new_provider):