Skip to content

Commit

Permalink
Resolve #45: Document request query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbalvanz-wf committed Oct 7, 2017
1 parent 5de7200 commit e728301
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,36 @@ configured and the interactions verified, use the `setup` and `verify` methods,
result = user('UserA')
# Some additional steps before verifying all interactions have occurred
pact.verify()
````
```

### Requests

When defining the expected HTTP request that your code is expected to make you
can specify the method, path, body, headers, and query:

```python
pact.with_request(
method='GET',
path='/api/v1/my-resources/',
query={'search': 'example'}
)
```

`query` is used to specify URL query parameters, so the above example expects
a request made to `/api/v1/my-resources/?search=example`.

```python
pact.with_request(
method='POST',
path='/api/v1/my-resources/123',
body={'user_ids': [1, 2, 3]},
headers={'Content-Type': 'application/json'},
)
```

You can define exact values for your expected request like the examples above,
or you can use the matchers defined later to assist in handling values that are
variable.

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

0 comments on commit e728301

Please sign in to comment.