test(integration): fix mirror tests by removing non-existent check_cmd patches
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / linter-shell (push) Has been cancelled
Mark stable commit / linter-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / linter-shell (push) Has been cancelled
Mark stable commit / linter-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
- Remove patches referencing pkgmgr.actions.mirror.check_cmd (module does not exist) - Patch actual mirror probe/remote helpers used at runtime - Make mirror integration tests deterministic and CI-safe https://chatgpt.com/share/693ee657-b260-800f-a69a-8b0680e6baa5
This commit is contained in:
@@ -59,8 +59,6 @@ class TestIntegrationMirrorCommands(unittest.TestCase):
|
|||||||
|
|
||||||
# Helper: patch with create=True so missing symbols don't explode.
|
# Helper: patch with create=True so missing symbols don't explode.
|
||||||
# IMPORTANT: patch() does not auto-import submodules when resolving dotted names.
|
# IMPORTANT: patch() does not auto-import submodules when resolving dotted names.
|
||||||
# Example failure: AttributeError: pkgmgr.actions.mirror has no attribute 'check_cmd'
|
|
||||||
# → so we import the parent module first (if it exists).
|
|
||||||
def _p(target: str, **kwargs):
|
def _p(target: str, **kwargs):
|
||||||
module_name = target.rsplit(".", 1)[0]
|
module_name = target.rsplit(".", 1)[0]
|
||||||
try:
|
try:
|
||||||
@@ -75,7 +73,9 @@ class TestIntegrationMirrorCommands(unittest.TestCase):
|
|||||||
def _fake_ensure_remote_repo(spec, provider_hint=None, options=None):
|
def _fake_ensure_remote_repo(spec, provider_hint=None, options=None):
|
||||||
# Safety: E2E should only ever call this in preview mode
|
# Safety: E2E should only ever call this in preview mode
|
||||||
if options is not None and getattr(options, "preview", False) is not True:
|
if options is not None and getattr(options, "preview", False) is not True:
|
||||||
raise AssertionError(f"{cmd_repr} attempted ensure_remote_repo without preview=True in E2E.")
|
raise AssertionError(
|
||||||
|
f"{cmd_repr} attempted ensure_remote_repo without preview=True in E2E."
|
||||||
|
)
|
||||||
r = MagicMock()
|
r = MagicMock()
|
||||||
r.status = "preview"
|
r.status = "preview"
|
||||||
r.message = "Preview mode (E2E patched): no remote provisioning performed."
|
r.message = "Preview mode (E2E patched): no remote provisioning performed."
|
||||||
@@ -94,14 +94,16 @@ class TestIntegrationMirrorCommands(unittest.TestCase):
|
|||||||
stack.enter_context(_p("pkgmgr.actions.mirror.merge_cmd.build_context", return_value=dummy_ctx))
|
stack.enter_context(_p("pkgmgr.actions.mirror.merge_cmd.build_context", return_value=dummy_ctx))
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.build_context", return_value=dummy_ctx))
|
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.build_context", return_value=dummy_ctx))
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.remote_provision.build_context", return_value=dummy_ctx))
|
stack.enter_context(_p("pkgmgr.actions.mirror.remote_provision.build_context", return_value=dummy_ctx))
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.check_cmd.build_context", return_value=dummy_ctx))
|
|
||||||
|
|
||||||
# setup_cmd imports ensure_origin_remote and probe_mirror directly:
|
# Deterministic remote probing (covers setup + likely check implementations)
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.ensure_origin_remote", return_value=None))
|
stack.enter_context(_p("pkgmgr.actions.mirror.remote_check.probe_mirror", return_value=(True, "")))
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.probe_mirror", return_value=(True, "")))
|
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.probe_mirror", return_value=(True, "")))
|
||||||
|
stack.enter_context(_p("pkgmgr.actions.mirror.git_remote.is_remote_reachable", return_value=True))
|
||||||
|
|
||||||
# check_cmd likely imports probe_mirror directly too (make it deterministic)
|
# setup_cmd imports ensure_origin_remote directly:
|
||||||
stack.enter_context(_p("pkgmgr.actions.mirror.check_cmd.probe_mirror", return_value=(True, "")))
|
stack.enter_context(_p("pkgmgr.actions.mirror.setup_cmd.ensure_origin_remote", return_value=None))
|
||||||
|
# Extra safety: if any code calls git_remote.ensure_origin_remote directly
|
||||||
|
stack.enter_context(_p("pkgmgr.actions.mirror.git_remote.ensure_origin_remote", return_value=None))
|
||||||
|
|
||||||
# remote provisioning: remote_provision imports ensure_remote_repo directly from core:
|
# remote provisioning: remote_provision imports ensure_remote_repo directly from core:
|
||||||
stack.enter_context(
|
stack.enter_context(
|
||||||
|
|||||||
Reference in New Issue
Block a user