1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Fix bug in ultra provider tests when run in Python 2.7

The test_login test from TestUltraProvider would fail in Python 2.7
due to the dictionary insertion order not being preserved in 2.7
and early 3.x versions. Comparing the dictionaries containing the
query parameters solves this. Snippet from test failure:

- username=user&password=rightpass&grant_type=password
+ grant_type=password&username=user&password=rightpass
This commit is contained in:
blanariu
2021-06-24 12:51:45 +03:00
parent 749f0bd90f
commit e934ea0423

View File

@@ -1,3 +1,12 @@
from __future__ import unicode_literals
try:
# Python 3
from urllib.parse import parse_qs
except ImportError:
# Python 2
from urlparse import parse_qs
from mock import Mock, call
from os.path import dirname, join
from requests import HTTPError
@@ -55,7 +64,8 @@ class TestUltraProvider(TestCase):
self.assertEquals(1, mock.call_count)
expected_payload = "grant_type=password&username=user&"\
"password=rightpass"
self.assertEquals(mock.last_request.text, expected_payload)
self.assertEquals(parse_qs(mock.last_request.text),
parse_qs(expected_payload))
def test_get_zones(self):
provider = _get_provider()