-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add matchers for ISO 8601 date format #333
Conversation
8b38b93
to
96bac1d
Compare
This introduces `pact.Format.iso_8601_datetime()` method to match a string for a full ISO 8601 Date. This method does not do any sort of date validation, only checks if the string is according to the ISO 8601 spec. It differs from `pact.Format.timestamp`, `pact.Format.date` and `pact.Format.time` implementations in that it is more stringent and tests the string for exact match to the ISO 8601 dates format. Without `with_ms` parameter will match string containing ISO 8601 formatted dates as stated bellow: * 2016-12-15T20:16:01 * 2010-05-01T01:14:31.876 * 2016-05-24T15:54:14.00000Z * 1994-11-05T08:15:30-05:00 * 2002-01-31T23:00:00.1234-02:00 * 1991-02-20T06:35:26.079043+00:00 Otherwise, ONLY dates with milliseconds will match the pattern: * 2010-05-01T01:14:31.876 * 2016-05-24T15:54:14.00000Z * 2002-01-31T23:00:00.1234-02:00 * 1991-02-20T06:35:26.079043+00:00 This change aims to bring the capabilities of the python library into alignment with pact-foundation/docs.pact.io#88, since the existing functionality is a bit liberal and allows tests to pass even in cases where the dates do not conform to the ISO 8601 spec.
fff6413
to
4919772
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! The only comment I have is that other languages let you specify the example value, whereas in this matcher it's hard coded.
It's consistent with the other matchers, so I think it's OK, but wanted to share that feedback.
@mefellows I'll definitely fix this, thank you for your comment. However, I would like to address it in a separate pull request. The issue is that there is currently hardcoded logic in all matchers, and I'd prefer to make a single, unified change to address this. |
Absolutely! Let's not hold up this change for that. |
Nice one, we've got a flakey build, but you get a mergey merge ( i just got one merging a docco change :( ) |
also thanks for updating the readme and adding a test |
This introduces
pact.Format.iso_8601_datetime()
method to match a string for a full ISO 8601 Date.This method does not do any sort of date validation, only checks if the string is according to the ISO 8601 spec.
It differs from
pact.Format.timestamp
,pact.Format.date
andpact.Format.time
implementations in that it is more stringent and tests the string for exact match to the ISO 8601 dates format.Without
with_ms
parameter will match string containing ISO 8601 formatted dates as stated bellow:Otherwise, ONLY dates with milliseconds will match the pattern:
This change aims to bring the capabilities of the python library into alignment with pact-foundation/docs.pact.io#88, since the existing functionality is a bit liberal and allows tests to pass even in cases where the dates do not conform to the ISO 8601 spec.