Commit 3bcd4b4
fix: migrate pact Verifier to pact-python 3.x API
pact-python 3.x (released after the 1.x series) ships a new Rust FFI-based
verifier that breaks backward compatibility with the old Ruby-based verifier.
The constructor and verification call both changed:
Old API (pact-python 1.x):
verifier = Verifier(provider='lms', provider_base_url=url)
output, _ = verifier.verify_pacts(pact_file, headers=[...], provider_states_setup_url=...)
assert output == 0
New API (pact-python 3.x):
Verifier(name='lms')
.add_transport(url=url)
.add_source(pact_file)
.add_custom_header('Pact-Authentication', 'Allow')
.state_handler(provider_states_setup_url, body=True)
.verify()
Key differences:
- `provider` → `name`, `provider_base_url` → `.add_transport(url=...)`
- `verify_pacts()` is gone; replaced by fluent `.add_source()` + `.verify()`
- Headers are set individually via `.add_custom_header(name, value)` rather
than as a list of `Key: Value` strings
- `provider_states_setup_url` becomes `.state_handler(url, body=True)`;
`body=True` is required for URL-based handlers and matches what the
provider state views already expect (they read from request.body)
- `verify()` raises RuntimeError on failure instead of returning a non-zero
exit code, so the `assert output == 0` is no longer needed
- The verifier is now created fresh inside the test method rather than in
setUpClass, because `add_source` and `add_custom_header` accumulate state
on the underlying FFI handle — sharing a verifier across multiple test
invocations would cause duplicate sources/headers on the second run
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>1 parent bbc3c64 commit 3bcd4b4
3 files changed
Lines changed: 30 additions & 59 deletions
File tree
- lms/djangoapps
- course_api/blocks/tests/pacts
- courseware/tests/pacts
- openedx/core/djangoapps/courseware_api/tests/pacts
Lines changed: 10 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 20 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
38 | 31 | | |
39 | | - | |
40 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 20 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
38 | 31 | | |
39 | | - | |
40 | | - | |
Lines changed: 10 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 23 | | |
39 | 24 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
44 | 35 | | |
45 | | - | |
46 | | - | |
0 commit comments