-
Couldn't load subscription status.
- Fork 56
Add test coverage for stac_api_io.py error handling #835
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
base: main
Are you sure you want to change the base?
Add test coverage for stac_api_io.py error handling #835
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #835 +/- ##
==========================================
+ Coverage 93.43% 94.82% +1.38%
==========================================
Files 13 15 +2
Lines 990 1217 +227
==========================================
+ Hits 925 1154 +229
+ Misses 65 63 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Test decode error in request() method - Test write to URL error in write_text_to_href() - Test unknown STAC object type error in stac_object_from_dict()
6667def to
feb1fb9
Compare
tests/test_stac_api_io.py
Outdated
| with open("tests/data/planetary-computer-collection.json") as f: | ||
| real_stac_data = json.load(f) |
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.
Could we just modify the real_stac_data with a bogus type attribute, instead of mocking the functions?
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.
@gadomski Back from travel and picking this up. identify_stac_object_type in pystac will raise a STACTypeError if the object type is not one of catalog, collection, or item (https://pystac.readthedocs.io/en/v1.12.2/_modules/pystac/serialization/identify.html#identify_stac_object). So I don't think the ValueError at line 290 in stac_api_io.py would ever be triggered, since pystac is catching type errors before then. I was mocking to get around that error, but should have dug deeper.
I'd suggest removing my test and marking the ValueError at line 290 with something like # pragma: no cover, since pystac should guarantee that we only get valid types. Alternatively, we could remove both. Do you have a preference?
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'm good with a pragma: no cover
Related Issue(s):
Description:
PR Checklist: