Error¶
Error classes for Pact.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
BodyMismatch(path: str, expected: str, actual: str, mismatch: str)
¶
Bases: Mismatch
Mismatch due to an incorrect body element.
PARAMETER | DESCRIPTION |
---|---|
path
|
Path expression to where the mismatch occurred.
TYPE:
|
expected
|
Expected value.
TYPE:
|
actual
|
Actual value.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|
Source code in src/pact/v3/error.py
BodyTypeMismatch(expected: str, actual: str, mismatch: str, expected_body: bytes | None = None, expectedBody: bytes | None = None, actual_body: bytes | None = None, actualBody: bytes | None = None)
¶
Bases: Mismatch
Mismatch due to an incorrect content type of the body.
PARAMETER | DESCRIPTION |
---|---|
expected
|
Expected content type of the body.
TYPE:
|
actual
|
Actual content type of the body.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|
expected_body
|
Expected body content.
TYPE:
|
actual_body
|
Actual body content.
TYPE:
|
expectedBody
|
Alias for
TYPE:
|
actualBody
|
Alias for
TYPE:
|
Source code in src/pact/v3/error.py
Attributes¶
actual: str
property
¶
Actual content type of the body.
actual_body: bytes | None
property
¶
Actual body content.
expected: str
property
¶
Expected content type of the body.
expected_body: bytes | None
property
¶
Expected body content.
mismatch: str
property
¶
Description of the mismatch.
type: str
property
¶
Type of the mismatch.
GenericMismatch(**kwargs: Any)
¶
HeaderMismatch(key: str, expected: str, actual: str, mismatch: str)
¶
Bases: Mismatch
Mismatch due to an incorrect header.
PARAMETER | DESCRIPTION |
---|---|
key
|
Header key.
TYPE:
|
expected
|
Expected value of the header.
TYPE:
|
actual
|
Actual value of the header.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|
Source code in src/pact/v3/error.py
InteractionVerificationError(description: str, error: Exception)
¶
Bases: PactError
Exception raised due during the verification of an interaction.
This error is raised when an error occurs during the manual verification of an
interaction. This is typically raised when the consumer fails to handle the
interaction correctly thereby generating its own exception. The cause of the
error is stored in the error
attribute.
PARAMETER | DESCRIPTION |
---|---|
description
|
Description of the interaction that failed verification.
TYPE:
|
error
|
Error that occurred during the verification of the interaction.
TYPE:
|
Source code in src/pact/v3/error.py
MetadataMismatch(key: str, expected: str, actual: str, mismatch: str)
¶
Bases: Mismatch
Mismatch due to incorrect message metadata.
PARAMETER | DESCRIPTION |
---|---|
key
|
Metadata key.
TYPE:
|
expected
|
Expected value.
TYPE:
|
actual
|
Actual value.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|
Source code in src/pact/v3/error.py
MethodMismatch(expected: str, actual: str)
¶
Mismatch
¶
Bases: ABC
A mismatch between the Pact contract and the actual interaction.
See https://github.com/pact-foundation/pact-reference/blob/f5ddf3d353149ae0fb539a1616eeb8544509fdfc/rust/pact_matching/src/lib.rs#L880 for the underlying source of the data.
Attributes¶
type: str
abstractmethod
property
¶
Type of the mismatch.
Functions¶
from_dict(data: dict[str, Any]) -> Mismatch
classmethod
¶
Create a new Mismatch from a dictionary.
PARAMETER | DESCRIPTION |
---|---|
data
|
Data for the mismatch. |
RETURNS | DESCRIPTION |
---|---|
Mismatch
|
A new Mismatch object. |
Source code in src/pact/v3/error.py
MismatchesError(*mismatches: Mismatch | dict[str, Any])
¶
Bases: PactError
Exception raised when there are mismatches between the Pact and the server.
PARAMETER | DESCRIPTION |
---|---|
mismatches
|
Mismatches between the Pact and the server. |
Source code in src/pact/v3/error.py
MissingRequest(method: str, path: str, request: dict[str, Any])
¶
Bases: Mismatch
Mismatch due to a missing request.
PARAMETER | DESCRIPTION |
---|---|
method
|
HTTP method of the missing request.
TYPE:
|
path
|
Path of the missing request.
TYPE:
|
request
|
Details of the missing request. |
Source code in src/pact/v3/error.py
PactVerificationError(errors: list[InteractionVerificationError])
¶
Bases: PactError
Exception raised due to errors in the verification of a Pact.
This is raised when performing manual verification of the Pact through the
verify
method:
pact = Pact("consumer", "provider")
# Define interactions...
try:
pact.verify(handler, kind="Async")
except PactVerificationError as e:
print(e.errors)
All of the errors that occurred during the verification of all of the
interactions are stored in the errors
attribute.
This is different from the [MismatchesError
][pact.v3.MismatchesError]
which is raised when there are mismatches detected by the mock server.
PARAMETER | DESCRIPTION |
---|---|
errors
|
Errors that occurred during the verification of the Pact.
TYPE:
|
Source code in src/pact/v3/error.py
PathMismatch(expected: str, actual: str, mismatch: str)
¶
QueryMismatch(parameter: str, expected: str, actual: str, mismatch: str)
¶
Bases: Mismatch
Mismatch due to an incorrect query parameter.
PARAMETER | DESCRIPTION |
---|---|
parameter
|
Query parameter name.
TYPE:
|
expected
|
Expected value of the query parameter.
TYPE:
|
actual
|
Actual value of the query parameter.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|
Source code in src/pact/v3/error.py
RequestMismatch(method: str, path: str, mismatches: list[dict[str, Any]])
¶
Bases: Mismatch
Mismatch due to an incorrect request.
PARAMETER | DESCRIPTION |
---|---|
method
|
HTTP method of the request.
TYPE:
|
path
|
Path of the request.
TYPE:
|
mismatches
|
List of mismatches in the request. |
Source code in src/pact/v3/error.py
RequestNotFound(method: str, path: str, request: dict[str, Any])
¶
Bases: Mismatch
Mismatch due to a request not being found.
PARAMETER | DESCRIPTION |
---|---|
method
|
HTTP method of the request not found.
TYPE:
|
path
|
Path of the request not found.
TYPE:
|
request
|
Details of the request not found. |
Source code in src/pact/v3/error.py
StatusMismatch(expected: int, actual: int, mismatch: str)
¶
Bases: Mismatch
Mismatch due to an incorrect HTTP status code.
PARAMETER | DESCRIPTION |
---|---|
expected
|
Expected HTTP status code.
TYPE:
|
actual
|
Actual HTTP status code.
TYPE:
|
mismatch
|
Description of the mismatch.
TYPE:
|