-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
133 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
class HeadersMatcher(object): | ||
def __init__(self, headers): | ||
self.headers = {} | ||
if not isinstance(headers, dict): | ||
raise TypeError('headers must be a dictionary') | ||
self.headers = headers | ||
|
||
def match(self, req): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,50 @@ | ||
import sys | ||
from .headers import HTTPHeaderDict | ||
from .utils import trigger_methods | ||
|
||
if sys.version_info < (3,): # Python 2 | ||
from urlparse import urlparse | ||
else: # Python 3 | ||
from urllib.parse import urlparse | ||
|
||
|
||
class Request(object): | ||
""" | ||
Request object representing the mock request expectation. | ||
Request object representing the request mock expectation. | ||
""" | ||
def __init__(self, method='GET', **args): | ||
self.method = method | ||
self.headers = HTTPHeaderDict() | ||
self.url = '' | ||
self.params = '' | ||
self.body = None | ||
self._method = method | ||
self._headers = HTTPHeaderDict() | ||
self._url = None | ||
self._body = None | ||
# Call methods | ||
trigger_methods(self, args) | ||
|
||
@property | ||
def method(self): | ||
return self._method | ||
|
||
@property | ||
def headers(self): | ||
return self._headers | ||
|
||
@headers.setter | ||
def headers(self, headers): | ||
self._headers.extend(headers) | ||
|
||
@property | ||
def url(self, url): | ||
return self._url | ||
|
||
@url.setter | ||
def url(self, url): | ||
self._url = urlparse(url) | ||
print('Parsed:', self._url) | ||
|
||
@property | ||
def body(self, data): | ||
return self._body | ||
|
||
@body.setter | ||
def body(self, body): | ||
self._body = body |