Skip to content

Commit

Permalink
Merge pull request #67 from jawu/enable-possibility-to-use-mathers-in…
Browse files Browse the repository at this point in the history
…-path

Enable possibility to use Matchers in path property of Request class
  • Loading branch information
matthewbalvanz-wf authored Dec 17, 2017
2 parents 8d438e4 + fb97d2f commit 149dfc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def catch_all(path):


if __name__ == '__main__':
app.run(port='5000')
app.run(port=5000)
4 changes: 2 additions & 2 deletions pact/pact.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __init__(self, method, path, body=None, headers=None, query=''):
:param method: The HTTP method that is expected.
:type method: str
:param path: The URI path that is expected on this request.
:type path: str
:type path: str, Matcher
:param body: The contents of the body of the expected request.
:type body: str, dict, list
:param headers: The headers of the expected request.
Expand All @@ -308,7 +308,7 @@ def __init__(self, method, path, body=None, headers=None, query=''):
:type query: str or dict
"""
self.method = method
self.path = path
self.path = from_term(path)
self.body = from_term(body)
self.headers = from_term(headers)
self.query = from_term(query)
Expand Down
7 changes: 6 additions & 1 deletion pact/test/test_pact.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mock import patch, call, Mock
from psutil import Process

from .. import Consumer, Provider, pact
from .. import Consumer, Provider, Term, pact
from ..constants import MOCK_SERVICE_PATH
from ..pact import Pact, FromTerms, Request, Response

Expand Down Expand Up @@ -476,6 +476,11 @@ def test_falsey_body(self):
'path': '/path',
'body': []})

def test_matcher_in_path_gets_converted(self):
target = Request('GET', Term('\/.+', '/test-path'))
result = target.json()
self.assertTrue(isinstance(result['path'], dict))


class ResponseTestCase(TestCase):
def test_sparse(self):
Expand Down

0 comments on commit 149dfc7

Please sign in to comment.