New behavior, new tests, added wizzard and processor

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-08-07 21:44:31 +02:00
parent f4ac509665
commit 1fef7bc404
8 changed files with 203 additions and 118 deletions

View File

@@ -523,3 +523,17 @@ def test_detector_run(cloner_dir_with_config):
cl.detector_run(callback_test)
assert repo_cloner.lib.cloner.Detector.run.called
assert called
def test_detector_init(cloner_dir_with_config):
ds = MockDirStruct(cloner_dir_with_config)
ds.config.cloner_repo_url = "https://mock"
mocks = {
'initialize_caches': MagicMock(),
}
with patch.multiple('repo_cloner.lib.cloner.Detector', **mocks):
cl = Cloner(ds)
cl.detector_init()
assert repo_cloner.lib.cloner.Detector.initialize_caches.called

View File

@@ -62,33 +62,33 @@ def test_config_try_override(tmp_path, path_repo_base, monkeypatch):
assert x == "[user]\n name = Loser\n"
def test_prepare_git_auth(tmp_path, path_repo_base, monkeypatch):
def test_prepare_git_auth(tmp_path, monkeypatch):
tmp_path.joinpath("git").mkdir()
cred_helper.token = None
with monkeypatch.context() as mp:
mp.setenv("XDG_CONFIG_HOME", tmp_path.as_posix())
prepare_git_auth(path_repo_base.as_posix(), tmp_path.as_posix())
prepare_git_auth(tmp_path.as_posix())
x = tmp_path.joinpath("git", "config")
assert x.exists()
config = x.read_text()
assert config == \
f"[credential]\n" \
f" helper = store --file={tmp_path.as_posix()}/git/git-credentials\n" \
f" helper = store --file={tmp_path.as_posix()}/auth/git-credentials\n" \
"[core]\n" \
f" sshcommand = ssh -i {tmp_path.as_posix()}/ssh/identity -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -q\n"
f" sshcommand = ssh -i {tmp_path.as_posix()}/auth/ssh/identity -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -q\n"
def test_prepare_git_auth_token(tmp_path, path_repo_base, monkeypatch):
def test_prepare_git_auth_token(tmp_path, monkeypatch):
# tmp_path.joinpath("git").mkdir()
with monkeypatch.context() as mp:
mp.setenv("XDG_CONFIG_HOME", tmp_path.as_posix())
cred_helper.token = "token123"
prepare_git_auth(path_repo_base.as_posix(), tmp_path.as_posix())
prepare_git_auth(tmp_path.as_posix())
x = tmp_path.joinpath("git", "config")
assert x.exists()
@@ -97,6 +97,6 @@ def test_prepare_git_auth_token(tmp_path, path_repo_base, monkeypatch):
"[url \"https://token123:x-oauth-basic@github.com/\"]\n" \
" insteadOf = https://github.com/\n" \
f"[credential]\n" \
f" helper = store --file={tmp_path.as_posix()}/git/git-credentials\n" \
f" helper = store --file={tmp_path.as_posix()}/auth/git-credentials\n" \
"[core]\n" \
f" sshcommand = ssh -i {tmp_path.as_posix()}/ssh/identity -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -q\n"
f" sshcommand = ssh -i {tmp_path.as_posix()}/auth/ssh/identity -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -q\n"