-
Notifications
You must be signed in to change notification settings - Fork 122
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
add custom validator as input #1320
Conversation
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.
This seems like a nice change! It would be great to have more information in the docstrings and some tests.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1320 +/- ##
=======================================
Coverage 91.18% 91.18%
=======================================
Files 51 51
Lines 7023 7024 +1
Branches 1005 1005
=======================================
+ Hits 6404 6405 +1
Misses 444 444
Partials 175 175 ☔ View full report in Codecov by Sentry. |
@jsignell I will look into adding a test. |
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.
Thanks for adding the test and docs!
@@ -183,6 +183,55 @@ def test_validates_geojson_with_tuple_coordinates(self) -> None: | |||
# Should not raise. | |||
item.validate() | |||
|
|||
@pytest.mark.vcr() |
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.
nice test! If you need vcr then there is probably a cassette file that you need to check in as well. In that case CI will fail. If CI passes then I think you don't need to have pytest.mark.vcr
here.
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.
I am not too familiar with VCR. I assume I need the same references that are contained in data-files/item/sample-item.json
? I simply reused that item from another test case.
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.
I took a look and it seems like this decorator is good enough. Don't need a new cassette as well.
@jsignell |
…ator dependency (relates to stac-utils/pystac#1320)
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.
This looks good to me! Thanks for your patience.
Related Issue(s):
Description:
Currently, performing validation on STAC objects with extensions that are not directly part of
pystac
, or that the schema is not yet published at the expected URI defined by the extension, is not convenient or obvious.In order to call
<STACObject>.validate()
, one has to either duplicate the operations done inpystac.validation.validate_dict
to use their own validator or set it globally withRegisteredValidator.set_validator
before calling<STACObject>.validate()
. This PR adds avalidator
input to all the relevant functions to directly provide the validator to use for validation, with a local reference. This makes it easier to manage the "active" validator at the moment thevalidate
method gets called.PR Checklist:
pre-commit
hooks pass locallyscripts/test
)