1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#!/usr/bin/python3
# Copyright (C) 2018-2020 Jelmer Vernooij
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Tests for the vcs module."""
from unittest import TestCase
from debmutate.vcs import (
VcsUrl,
gbp_expand_tag_name,
mangle_version_for_git,
split_vcs_url,
unsplit_vcs_url,
)
class SplitVcsUrlTests(TestCase):
def test_none(self):
self.assertEqual(
VcsUrl("https://github.com/jelmer/example", None, None),
split_vcs_url("https://github.com/jelmer/example"),
)
self.assertEqual(
VcsUrl("https://github.com/jelmer/example", None, "path/to/packaging"),
split_vcs_url("https://github.com/jelmer/example [path/to/packaging]"),
)
def test_branch(self):
self.assertEqual(
VcsUrl("https://github.com/jelmer/example", "master", "path/to/packaging"),
split_vcs_url(
"https://github.com/jelmer/example [path/to/packaging] -b master"
),
)
self.assertEqual(
VcsUrl("https://github.com/jelmer/example", "master", "path/to/packaging"),
split_vcs_url(
"https://github.com/jelmer/example -b master [path/to/packaging]"
),
)
self.assertEqual(
VcsUrl("https://github.com/jelmer/example", "master", None),
split_vcs_url("https://github.com/jelmer/example -b master"),
)
class UnsplitVcsUrlTests(TestCase):
def test_none(self):
self.assertEqual(
"https://github.com/jelmer/example",
unsplit_vcs_url("https://github.com/jelmer/example", None, None),
)
self.assertEqual(
"https://github.com/jelmer/example [path/to/packaging]",
unsplit_vcs_url(
"https://github.com/jelmer/example", None, "path/to/packaging"
),
)
def test_branch(self):
self.assertEqual(
"https://github.com/jelmer/example -b master [path/to/packaging]",
unsplit_vcs_url(
"https://github.com/jelmer/example", "master", "path/to/packaging"
),
)
self.assertEqual(
"https://github.com/jelmer/example -b master",
unsplit_vcs_url("https://github.com/jelmer/example", "master", None),
)
class MangleVersionForGitTests(TestCase):
def test_replace_tilde(self):
self.assertEqual("1.0_1", mangle_version_for_git("1.0~1"))
def test_normal(self):
self.assertEqual("1.0", mangle_version_for_git("1.0"))
class ExpandGbpTagFormatTests(TestCase):
def test_gbp_tag_format(self):
self.assertEqual("blah-1.0", gbp_expand_tag_name("blah-%(version)s", "1.0"))
self.assertEqual(
"blah-0.1-1", gbp_expand_tag_name("blah-%(version%~%-)s", "0.1~1")
)
|