Add test coverage for stac_api_io.py error handling#835
Add test coverage for stac_api_io.py error handling#835nlebovits wants to merge 3 commits intostac-utils:mainfrom
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.
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.
@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.
👍🏼 I'm good with a pragma: no cover
Related Issue(s):
Description:
PR Checklist: