import pytest from scribe.services.repo_bindings import normalize_repo_key @pytest.mark.parametrize( "raw", [ "git@git.fabledsword.com:bvandeusen/fabledscribe.git", "git@git.fabledsword.com:bvandeusen/FabledScribe.git", "https://git.fabledsword.com/bvandeusen/fabledscribe.git", "https://git.fabledsword.com/bvandeusen/fabledscribe", "http://git.fabledsword.com/bvandeusen/fabledscribe.git", "ssh://git@git.fabledsword.com:22/bvandeusen/fabledscribe.git", "ssh://git@git.fabledsword.com/bvandeusen/fabledscribe", "https://user:token@git.fabledsword.com/bvandeusen/fabledscribe.git", ], ) def test_normalize_collapses_equivalent_remotes(raw): assert normalize_repo_key(raw) == "git.fabledsword.com/bvandeusen/fabledscribe" @pytest.mark.parametrize("raw", ["", " ", None]) def test_normalize_empty_inputs(raw): assert normalize_repo_key(raw) == "" def test_normalize_distinguishes_different_repos(): a = normalize_repo_key("git@host:owner/repo-a.git") b = normalize_repo_key("git@host:owner/repo-b.git") assert a == "host/owner/repo-a" assert b == "host/owner/repo-b" assert a != b def test_normalize_preserves_nested_group_path(): # GitLab-style nested namespaces must survive normalization. assert ( normalize_repo_key("https://gitlab.com/group/subgroup/repo.git") == "gitlab.com/group/subgroup/repo" )