subscription-manager icon indicating copy to clipboard operation
subscription-manager copied to clipboard

2093291: Make reading of cache file more reliable

Open jirihnidek opened this issue 3 years ago • 1 comments

  • 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

jirihnidek avatar Sep 26 '22 10:09 jirihnidek

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.py already 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 cp command would be only little bit different.

BTW: I removed test_dnf_content_plugin.py, because it actually didn't test anything.

jirihnidek avatar Oct 05 '22 10:10 jirihnidek

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!

ptoscano avatar May 24 '23 11:05 ptoscano

Coverage

Coverage (computed on Fedora latest) •
FileStmtsMissCoverMissing
__init__.py00100% 
plugins/dnf
   product_id.py15710235%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
TOTAL18100440775% 

Tests Skipped Failures Errors Time
2631 9 :zzz: 0 :x: 0 :fire: 57.070s :stopwatch:

github-actions[bot] avatar May 24 '23 13:05 github-actions[bot]

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.

jirihnidek avatar May 24 '23 13:05 jirihnidek

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.

ptoscano avatar May 25 '23 06:05 ptoscano