debian-todo/tests/test_vcs.py
2026-02-01 14:02:53 +00:00

71 lines
2.6 KiB
Python

"""Tests for VCS and uploader related functions."""
import pytest
from debian_todo import vcs_git_to_team, normalize_uploaders, HIDE_UPLOADER
class TestVcsGitToTeam:
"""Tests for vcs_git_to_team function."""
def test_salsa_python_team(self):
url = "https://salsa.debian.org/python-team/packages/python-foo.git"
assert vcs_git_to_team(url) == "python-team"
def test_salsa_homeassistant_team(self):
url = "https://salsa.debian.org/homeassistant-team/python-bar.git"
assert vcs_git_to_team(url) == "homeassistant-team"
def test_salsa_personal_repo(self):
url = "https://salsa.debian.org/username/package.git"
assert vcs_git_to_team(url) == "username"
def test_non_salsa_url(self):
url = "https://github.com/user/repo.git"
assert vcs_git_to_team(url) == url
def test_none_input(self):
assert vcs_git_to_team(None) is None
def test_empty_string(self):
assert vcs_git_to_team("") is None
def test_salsa_with_branch(self):
url = "https://salsa.debian.org/python-team/packages/foo.git -b debian/main"
assert vcs_git_to_team(url) == "python-team"
class TestNormalizeUploaders:
"""Tests for normalize_uploaders function."""
def test_single_uploader(self):
uploaders = "John Doe <john@example.com>"
assert normalize_uploaders(uploaders) == "John Doe <john@example.com>"
def test_multiple_uploaders(self):
uploaders = "John Doe <john@example.com>, Jane Doe <jane@example.com>"
result = normalize_uploaders(uploaders)
assert result == "John Doe <john@example.com>\nJane Doe <jane@example.com>"
def test_hides_configured_uploader(self):
uploaders = f"John Doe <john@example.com>, {HIDE_UPLOADER}"
result = normalize_uploaders(uploaders)
assert result == "John Doe <john@example.com>"
assert HIDE_UPLOADER not in result
def test_only_hidden_uploader(self):
uploaders = HIDE_UPLOADER
assert normalize_uploaders(uploaders) == ""
def test_strips_whitespace(self):
uploaders = " John Doe <john@example.com> , Jane Doe <jane@example.com> "
result = normalize_uploaders(uploaders)
assert result == "John Doe <john@example.com>\nJane Doe <jane@example.com>"
def test_empty_string(self):
assert normalize_uploaders("") == ""
def test_extra_commas(self):
uploaders = "John Doe <john@example.com>,, Jane Doe <jane@example.com>,"
result = normalize_uploaders(uploaders)
assert result == "John Doe <john@example.com>\nJane Doe <jane@example.com>"