1919
2020
2121import atom .http_interface
22+ import atom .url
2223
2324
2425class Error (Exception ):
@@ -32,6 +33,8 @@ class NoRecordingFound(Error):
3233class MockRequest (object ):
3334 def __init__ (self , operation , url , data = None , headers = None ):
3435 self .operation = operation
36+ if isinstance (url , (str , unicode )):
37+ url = atom .url .parse_url (url )
3538 self .url = url
3639 self .data = data
3740 self .headers = headers
@@ -94,7 +97,7 @@ def add_response(self, response, operation, url, data=None, headers=None):
9497 headers: dict of strings: Currently the headers are ignored when
9598 looking for matching requests.
9699 """
97- request = MockRequest (operation , str ( url ) , data = data , headers = headers )
100+ request = MockRequest (operation , url , data = data , headers = headers )
98101 self .recordings .append ((request , response ))
99102
100103 def request (self , operation , url , data = None , headers = None ):
@@ -106,8 +109,8 @@ def request(self, operation, url, data=None, headers=None):
106109 If there is no match, a NoRecordingFound error will be raised.
107110 """
108111 if self .real_client is None :
109- if url :
110- url = str (url )
112+ if isinstance ( url , ( str , unicode )) :
113+ url = atom . url . parse_url (url )
111114 for recording in self .recordings :
112115 if recording [0 ].operation == operation and recording [0 ].url == url :
113116 return recording [1 ]
0 commit comments