Modify MyURLComparator to handle deep match on URL
MyURLComparator equals method is enhanced to perfom url comparison based on url parts such as scheme, netloc, path and query instead of raw string comparison. pagination methods are modified to wrap the url requests with pagination params within MyURLComparator objects. Change-Id: I69b835dce64d662d1af6a14556fb8281e3b04d63 Closes-Bug: #1617480
This commit is contained in:
parent
542a2bb083
commit
f6848f0f31
|
@ -21,6 +21,7 @@ import cStringIO
|
|||
import fixtures
|
||||
import mox
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import sys
|
||||
import testtools
|
||||
|
||||
|
@ -85,7 +86,17 @@ class MyUrlComparator(mox.Comparator):
|
|||
self.client = client
|
||||
|
||||
def equals(self, rhs):
|
||||
return str(self) == rhs
|
||||
lhsp = urlparse.urlparse(self.lhs)
|
||||
rhsp = urlparse.urlparse(rhs)
|
||||
|
||||
lhs_qs = urlparse.parse_qsl(lhsp.query)
|
||||
rhs_qs = urlparse.parse_qsl(rhsp.query)
|
||||
|
||||
return (lhsp.scheme == rhsp.scheme and
|
||||
lhsp.netloc == rhsp.netloc and
|
||||
lhsp.path == rhsp.path and
|
||||
len(lhs_qs) == len(rhs_qs) and
|
||||
set(lhs_qs) == set(rhs_qs))
|
||||
|
||||
def __str__(self):
|
||||
if self.client and self.client.format != FORMAT:
|
||||
|
@ -491,9 +502,9 @@ class CLITestV10Base(testtools.TestCase):
|
|||
headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr1))
|
||||
self.client.httpclient.request(
|
||||
end_url(path % myid, fake_query, format=self.format), 'GET',
|
||||
body=None,
|
||||
headers=mox.ContainsKeyValue(
|
||||
MyUrlComparator(end_url(path % myid, fake_query,
|
||||
format=self.format), self.client), 'GET',
|
||||
body=None, headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr2))
|
||||
self.mox.ReplayAll()
|
||||
cmd_parser = cmd.get_parser("list_" + resources)
|
||||
|
@ -523,8 +534,8 @@ class CLITestV10Base(testtools.TestCase):
|
|||
headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr1))
|
||||
self.client.httpclient.request(
|
||||
end_url(path, fake_query, format=self.format), 'GET',
|
||||
body=None,
|
||||
MyUrlComparator(end_url(path, fake_query, format=self.format),
|
||||
self.client), 'GET', body=None,
|
||||
headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr2))
|
||||
self.mox.ReplayAll()
|
||||
|
|
Loading…
Reference in New Issue