/usr/lib/python2.7/dist-packages/betamax/matchers/query.py is in python-betamax 0.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # -*- coding: utf-8 -*-
from .base import BaseMatcher
from requests.compat import urlparse
try:
from urlparse import parse_qs
except ImportError:
from urllib.parse import parse_qs
class QueryMatcher(BaseMatcher):
# Matches based on the query of the request
name = 'query'
def to_dict(self, query):
"""Turn the query string into a dictionary."""
return parse_qs(query or '') # Protect against None
def match(self, request, recorded_request):
request_query = self.to_dict(urlparse(request.url).query)
recorded_query = self.to_dict(
urlparse(recorded_request['uri']).query
)
return request_query == recorded_query
|