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 / lint-shell (push) Has been cancelled
Mark stable commit / lint-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
- Treat MIRRORS as the only authority for mirror URLs - Filter non-git URLs (e.g. PyPI) from git remotes and push URLs - Prefer SSH git URLs when determining primary origin - Ensure mirror probing only targets valid git remotes - Refactor repository create into service-based architecture - Write PyPI metadata exclusively to MIRRORS, never to git config - Add integration test verifying PyPI is not written into .git/config - Update preview and unit tests to match new create flow https://chatgpt.com/share/69415c61-1c5c-800f-86dd-0405edec25db
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
import io
|
|
import unittest
|
|
from contextlib import redirect_stdout
|
|
from unittest.mock import patch
|
|
|
|
from pkgmgr.actions.repository.create import create_repo
|
|
|
|
|
|
class TestCreateRepoPreviewOutput(unittest.TestCase):
|
|
def test_create_repo_preview_prints_expected_steps(self) -> None:
|
|
cfg = {"directories": {"repositories": "/tmp/Repositories"}, "repositories": []}
|
|
|
|
out = io.StringIO()
|
|
with (
|
|
redirect_stdout(out),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.config_writer.generate_alias",
|
|
return_value="repo",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.config_writer.save_user_config",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.config_writer.os.path.exists",
|
|
return_value=False,
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.service.os.makedirs",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.templates.TemplateRenderer._resolve_templates_dir",
|
|
return_value="/tpl",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.templates.os.walk",
|
|
return_value=[("/tpl", [], ["README.md.j2"])],
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.git_bootstrap.init",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.git_bootstrap.add_all",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.git_bootstrap.commit",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.mirrors.write_mirrors_file",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.mirrors.setup_mirrors",
|
|
),
|
|
patch(
|
|
"pkgmgr.actions.repository.create.service.get_config_value",
|
|
return_value=None,
|
|
),
|
|
):
|
|
create_repo(
|
|
"github.com/acme/repo",
|
|
cfg,
|
|
"/tmp/user.yml",
|
|
"/tmp/bin",
|
|
remote=False,
|
|
preview=True,
|
|
)
|
|
|
|
s = out.getvalue()
|
|
self.assertIn("[Preview] Would add repository to config:", s)
|
|
self.assertIn("[Preview] Would ensure directory exists:", s)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|