Skip to content

Conversation

@chrislawlor
Copy link

@chrislawlor chrislawlor commented Aug 11, 2021

Adds the match common formats feature from pact-python:

from pact import Format
Format().integer  # Matches if the value is an integer
Format().ip_address  # Matches if the value is a ip address

can be used in place of other matchers:

from pact import Like, Format
Like({
    'id': Format().integer, # integer
    'lastUpdated': Format().timestamp, # timestamp
    'location': { # dictionary
        'host': Format().ip_address # ip address
    }
})

Supported formats:

matcher description
identifier Match an ID (e.g. 42)
integer Match all numbers that are integers (both ints and longs)
decimal Match all real numbers (floating point and decimal)
hexadecimal Match all hexadecimal encoded strings
date Match string containing basic ISO8601 dates (e.g. 2016-01-01)
timestamp Match a string containing an RFC3339 formatted timestapm (e.g. Mon, 31 Oct 2016 15:21:41 -0400)
time Match string containing times in ISO date format (e.g. T22:44:30.652Z)
ip_address Match string containing IP4 formatted address
ipv6_address Match string containing IP6 formatted address
uuid Match strings containing UUIDs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant