Skip to content

Commit a59fa1d

Browse files
committed
Added ModuleBase mocking for appstreams unit tests
Mock dnf.module.module_base to support testing the ModuleBase API refactoring. Without this mock, the import sets dnf.module=None and tests fail when trying to access module_base.ModuleBase().
1 parent 828088b commit a59fa1d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

promise-types/appstreams/test_appstreams_logic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
# Mock dnf module before importing the promise module
1414
mock_dnf = MagicMock()
1515
mock_dnf.exceptions = MagicMock()
16+
mock_dnf.module = MagicMock()
17+
mock_dnf.module.module_base = MagicMock()
1618
sys.modules["dnf"] = mock_dnf
1719
sys.modules["dnf.exceptions"] = mock_dnf.exceptions
20+
sys.modules["dnf.module"] = mock_dnf.module
21+
sys.modules["dnf.module.module_base"] = mock_dnf.module.module_base
1822

1923
import appstreams as appstreams_module # noqa: E402
2024

0 commit comments

Comments
 (0)