Updated Branches:
  refs/heads/0.13.3 [created] a1fdac91e
Updated Tags:  refs/tags/0.12.1-tenative [created] 961430045
  refs/tags/0.12.4-tenative [created] 7ba799d06
  refs/tags/0.13.0-tenative [created] 9c0d11a4c
  refs/tags/0.14.0-beta1-tenative [created] 25fa11f8a
  refs/tags/0.14.0-beta2-tenative [created] 99bd8739a
  refs/tags/0.14.0-beta3-tenative [created] 5ef0707b2
  refs/tags/v0.13.3-tenative [created] a1fdac91e


Add assertUrlContainsQueryParams method to MockHttpTestCase class and modify
affected tests to use it.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/617f6321
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/617f6321
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/617f6321

Branch: refs/heads/0.13.3
Commit: 617f632112d7bc026b7661c0433c68d2639b849c
Parents: c4b3daa
Author: Tomaz Muraus <[email protected]>
Authored: Tue Nov 5 11:00:14 2013 +0000
Committer: Tomaz Muraus <[email protected]>
Committed: Mon Dec 30 23:15:54 2013 +0100

----------------------------------------------------------------------
 libcloud/test/__init__.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/617f6321/libcloud/test/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/test/__init__.py b/libcloud/test/__init__.py
index 86fcc47..4ea4fe9 100644
--- a/libcloud/test/__init__.py
+++ b/libcloud/test/__init__.py
@@ -20,6 +20,7 @@ from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import StringIO
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import parse_qs
+from libcloud.utils.py3 import parse_qsl
 from libcloud.utils.py3 import u
 from libcloud.utils.py3 import unittest2_required
 
@@ -218,6 +219,34 @@ class MockHttpTestCase(MockHttp, unittest.TestCase):
     def runTest(self):
         pass
 
+    def assertUrlContainsQueryParams(self, url, expected_params, strict=False):
+        """
+        Assert that provided url contains provided query parameters.
+
+        :param url: URL to assert.
+        :type url: ``str``
+
+        :param expected_params: Dictionary of expected query parameters.
+        :type expected_params: ``dict``
+
+        :param strict: Assert that provided url contains only expected_params.
+                       (defaults to ``False``)
+        :type strict: ``bool``
+        """
+        question_mark_index = url.find('?')
+
+        if question_mark_index != -1:
+            url = url[question_mark_index + 1:]
+
+        params = dict(parse_qsl(url))
+
+        if strict:
+            self.assertDictEqual(params, expected_params)
+        else:
+            for key, value in expected_params.items():
+                self.assertEqual(params[key], value)
+
+
 class StorageMockHttp(MockHttp):
     def putrequest(self, method, action):
         pass

Reply via email to