Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added has_query_params method which can be useful in tests

  • Loading branch information...
commit b3fd0ddd8fae357178d1c0e05d0d5e9b51a4ee02 1 parent ebaeb5d
@codeinthehole authored
Showing with 9 additions and 0 deletions.
  1. +3 −0  purl/__init__.py
  2. +6 −0 purl/tests.py
View
3  purl/__init__.py
@@ -121,6 +121,9 @@ def path_segments(self):
def has_query_param(self, key):
return self.query_param(key) is not None
+ def has_query_params(self, keys):
+ return all([self.has_query_param(k) for k in keys])
+
def query_param(self, key, value=None, default=None, as_list=False):
"""
Return a query parameter for the given key
View
6 purl/tests.py
@@ -89,6 +89,12 @@ def setUp(self):
def test_has_actual_param(self):
self.assertTrue(self.url.has_query_param('q'))
+ def test_has_query_params(self):
+ self.assertTrue(self.url.has_query_params(['q']))
+
+ def test_has_query_params_negative(self):
+ self.assertFalse(self.url.has_query_params(['q', 'r']))
+
def test_netloc(self):
self.assertEqual('www.google.com', self.url.netloc())
Please sign in to comment.
Something went wrong with that request. Please try again.