Fix invalid HDF5 path error handling - #550
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #550 +/- ##
==========================================
+ Coverage 47.86% 47.88% +0.01%
==========================================
Files 95 95
Lines 7673 7673
Branches 669 669
==========================================
+ Hits 3673 3674 +1
+ Misses 3808 3807 -1
Partials 192 192 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JamesOHeaDLS
left a comment
There was a problem hiding this comment.
Thanks @MahirAbbas - looks good, and I appreciate you making a test to go with it.
I've only made 2 minor suggestions for changes.
Also, thanks for introducing me to caplog - that is new to me and I'm going to start using it in my code
| assert "Failed to create file" in caplog.text | ||
| assert "PermissionError" in caplog.text | ||
| assert "Permission denied" in caplog.text |
There was a problem hiding this comment.
Could be reduced to assert str(error) in caplog.text
| error = PermissionError(13, "Permission denied", "/invalid/test_meta.h5") | ||
|
|
||
| with patch("odin_data.meta_writer.meta_writer.h5py.File", side_effect=error): | ||
| with caplog.at_level(logging.ERROR): | ||
| writer._create_file("/invalid/test_meta.h5", dataset_size=1) |
There was a problem hiding this comment.
Minor tweak to avoid repetition - bring "/invalid/test_meta.h5" out into a variable which is used in error and the create_file call
Fixes #412 and adds test for it