-
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.
feat(core): add base matcher with string friendly output
- Loading branch information
Showing
8 changed files
with
44 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
class BodyMatcher(object): | ||
from .base import BaseMatcher | ||
|
||
|
||
class BodyMatcher(BaseMatcher): | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
class HeadersMatcher(object): | ||
from .base import BaseMatcher | ||
|
||
|
||
class HeadersMatcher(BaseMatcher): | ||
def __init__(self, headers): | ||
if not isinstance(headers, dict): | ||
raise TypeError('headers must be a dictionary') | ||
self.headers = headers | ||
self.expectation = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .base import BaseMatcher | ||
|
||
|
||
class JSONBodyMatcher(BaseMatcher): | ||
def __init__(self, headers): | ||
self.expectation = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
class MethodMatcher(object): | ||
from .base import BaseMatcher | ||
|
||
|
||
class MethodMatcher(BaseMatcher): | ||
def __init__(self, method): | ||
self.method = method | ||
self.expectation = method | ||
|
||
def match(self, req): | ||
return self.method == '*' or req.method == self.method | ||
return self.expectation == '*' or req.expectation == self.method |
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,9 @@ | ||
class QueryMatcher(object): | ||
from .base import BaseMatcher | ||
|
||
|
||
class QueryMatcher(BaseMatcher): | ||
def __init__(self, params): | ||
self.params = params | ||
self.expectation = params | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
class URLMatcher(object): | ||
from .base import BaseMatcher | ||
|
||
|
||
class URLMatcher(BaseMatcher): | ||
def __init__(self, expression): | ||
self.expression = expression | ||
self.expectation = expression | ||
|
||
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