Skip to content

Commit e728301

Browse files
Resolve #45: Document request query parameter
1 parent 5de7200 commit e728301

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,36 @@ configured and the interactions verified, use the `setup` and `verify` methods,
102102
result = user('UserA')
103103
# Some additional steps before verifying all interactions have occurred
104104
pact.verify()
105-
````
105+
```
106+
107+
### Requests
108+
109+
When defining the expected HTTP request that your code is expected to make you
110+
can specify the method, path, body, headers, and query:
111+
112+
```python
113+
pact.with_request(
114+
method='GET',
115+
path='/api/v1/my-resources/',
116+
query={'search': 'example'}
117+
)
118+
```
119+
120+
`query` is used to specify URL query parameters, so the above example expects
121+
a request made to `/api/v1/my-resources/?search=example`.
122+
123+
```python
124+
pact.with_request(
125+
method='POST',
126+
path='/api/v1/my-resources/123',
127+
body={'user_ids': [1, 2, 3]},
128+
headers={'Content-Type': 'application/json'},
129+
)
130+
```
131+
132+
You can define exact values for your expected request like the examples above,
133+
or you can use the matchers defined later to assist in handling values that are
134+
variable.
106135

107136
The default hostname and port for the Pact mock service will be
108137
`localhost:1234` but you can adjust this during Pact creation:

0 commit comments

Comments
 (0)