Skip to content

Commit 149dfc7

Browse files
Merge pull request #67 from jawu/enable-possibility-to-use-mathers-in-path
Enable possibility to use Matchers in path property of Request class
2 parents 8d438e4 + fb97d2f commit 149dfc7

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

e2e/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ def catch_all(path):
6161

6262

6363
if __name__ == '__main__':
64-
app.run(port='5000')
64+
app.run(port=5000)

pact/pact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def __init__(self, method, path, body=None, headers=None, query=''):
299299
:param method: The HTTP method that is expected.
300300
:type method: str
301301
:param path: The URI path that is expected on this request.
302-
:type path: str
302+
:type path: str, Matcher
303303
:param body: The contents of the body of the expected request.
304304
:type body: str, dict, list
305305
:param headers: The headers of the expected request.
@@ -308,7 +308,7 @@ def __init__(self, method, path, body=None, headers=None, query=''):
308308
:type query: str or dict
309309
"""
310310
self.method = method
311-
self.path = path
311+
self.path = from_term(path)
312312
self.body = from_term(body)
313313
self.headers = from_term(headers)
314314
self.query = from_term(query)

pact/test/test_pact.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from mock import patch, call, Mock
66
from psutil import Process
77

8-
from .. import Consumer, Provider, pact
8+
from .. import Consumer, Provider, Term, pact
99
from ..constants import MOCK_SERVICE_PATH
1010
from ..pact import Pact, FromTerms, Request, Response
1111

@@ -476,6 +476,11 @@ def test_falsey_body(self):
476476
'path': '/path',
477477
'body': []})
478478

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

480485
class ResponseTestCase(TestCase):
481486
def test_sparse(self):

0 commit comments

Comments
 (0)