summaryrefslogtreecommitdiff
path: root/troveclient/tests/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'troveclient/tests/utils.py')
-rw-r--r--troveclient/tests/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/troveclient/tests/utils.py b/troveclient/tests/utils.py
index c3e81ac..a912649 100644
--- a/troveclient/tests/utils.py
+++ b/troveclient/tests/utils.py
@@ -23,6 +23,22 @@ AUTH_URL = "http://localhost:5002/auth_url"
AUTH_URL_V1 = "http://localhost:5002/auth_url/v1.0"
AUTH_URL_V2 = "http://localhost:5002/auth_url/v2.0"
+URL_QUERY_SEPARATOR = '&'
+URL_SEPARATOR = '?'
+
+
+def order_url(url):
+ """Returns the url with the query strings ordered, if they exist and
+ there's more than one. Otherwise the url is returned unaltered.
+ """
+ if URL_QUERY_SEPARATOR in url:
+ parts = url.split(URL_SEPARATOR)
+ if len(parts) == 2:
+ queries = sorted(parts[1].split(URL_QUERY_SEPARATOR))
+ url = URL_SEPARATOR.join(
+ [parts[0], URL_QUERY_SEPARATOR.join(queries)])
+ return url
+
def _patch_mock_to_raise_for_invalid_assert_calls():
def raise_for_invalid_assert_calls(wrapped):