2093291: Make reading of cache file more reliable
- BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2093291
- Make code testable, renamed some files and modified Makefile
- Do not write traceback to rhsm.log, when it is not possible to read/write to the cache file
- Added few unit tests for this case
I think that, rather than renaming all the files of dnf plugins (which adds more complication when installing, and when testing on your own overriding the system files), a better way would be keeping this complication due to the '-' only in unit test; after all, the existing
test_dnf_content_plugin.pyalready deals with this:https://github.com/candlepin/subscription-manager/blob/b31cb8aa032f37ccb236d4b693e057f79a659389/test/test_dnf_content_plugin.py#L17-L36
All Python source files inside ./src should be Python modules. Python modules just cannot contain '-'. When we install these modules, then we sometimes alter these modules and their names to something else like subscription_manager.py is altered by setuptools to subscription-manager, but I don't see any reason, why ./src should contain any *.py file that is not Python module.
"which adds more complication when installing, and when testing on your own overriding the system files"
- Installation is already solved in this PR
- When you want to test it by overriding the system file, then using
cpcommand would be only little bit different.
BTW: I removed test_dnf_content_plugin.py, because it actually didn't test anything.
I'm still not a fan of renaming the plugin files: they are not Python modules, but rather sources loaded/eval'ed by dnf; that said, I'm willing to give this approach a go.
I see there were test failures in the added TestDnfPluginProductId, so they need to be fixed; also, since there are conflicts due to the other changes, a rebase will also help to review this, especially after the recent lock-related changes.
Thanks!
Coverage (computed on Fedora latest) •
File Stmts Miss Cover Missing __init__.py 0 0 100% plugins/dnf product_id.py 157 102 35% 41–44, 47, 50–54, 60, 62, 64–68, 70–77, 86–87, 90, 93–96, 98–102, 104, 106–111, 117–120, 123–136, 140–144, 146–147, 149–150, 152, 160–164, 176–180, 182, 187–191, 206, 210–212, 215, 219, 222, 230–231, 233–234, 238, 240, 242 TOTAL 18100 4407 75%
| Tests | Skipped | Failures | Errors | Time |
|---|---|---|---|---|
| 2631 | 9 :zzz: | 0 :x: | 0 :fire: | 57.070s :stopwatch: |
Re-based. Fixed issues with unit tests, warning message and stylish issues. I will test it more, because I updated this PR 3 months ago.
I will test it more, because I updated this PR 3 months ago.
No problem, thanks for the work!
I'll mark this as draft in the meanwhile, so it's easier to spot as "being worked on" PR. Of course, feel free to un-draft it and poke once ready.