Add tests.
This commit is contained in:
parent
e80f511155
commit
a7d4bc4ae9
10 changed files with 915 additions and 418 deletions
71
tests/test_vcs.py
Normal file
71
tests/test_vcs.py
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
"""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>"
|
||||
Loading…
Add table
Add a link
Reference in a new issue