File: test_vcs.py

package info (click to toggle)
python-upstream-ontologist 0.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 396 kB
  • sloc: python: 262; makefile: 25
file content (99 lines) | stat: -rw-r--r-- 3,498 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python3
# Copyright (C) 2018 Jelmer Vernooij <jelmer@debian.org>
#
# 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


from unittest import TestCase

from upstream_ontologist.vcs import (
    canonical_git_repo_url,
    find_public_repo_url,
    fixup_rcp_style_git_repo_url,
)


class CanonicalizeVcsUrlTests(TestCase):
    def test_github(self):
        self.assertEqual(
            "https://github.com/jelmer/example.git",
            canonical_git_repo_url("https://github.com/jelmer/example"),
        )

    def test_salsa(self):
        self.assertEqual(
            "https://salsa.debian.org/jelmer/example.git",
            canonical_git_repo_url("https://salsa.debian.org/jelmer/example"),
        )
        self.assertEqual(
            "https://salsa.debian.org/jelmer/example.git",
            canonical_git_repo_url("https://salsa.debian.org/jelmer/example.git"),
        )


class FindPublicVcsUrlTests(TestCase):
    def test_github(self):
        self.assertEqual(
            "https://github.com/jelmer/example",
            find_public_repo_url("ssh://git@github.com/jelmer/example"),
        )
        self.assertEqual(
            "https://github.com/jelmer/example",
            find_public_repo_url("https://github.com/jelmer/example"),
        )
        self.assertEqual(
            "https://github.com/jelmer/example",
            find_public_repo_url("git@github.com:jelmer/example"),
        )

    def test_salsa(self):
        self.assertEqual(
            "https://salsa.debian.org/jelmer/example",
            find_public_repo_url("ssh://salsa.debian.org/jelmer/example"),
        )
        self.assertEqual(
            "https://salsa.debian.org/jelmer/example",
            find_public_repo_url("https://salsa.debian.org/jelmer/example"),
        )


class FixupRcpStyleUrlTests(TestCase):
    def test_fixup(self):
        try:
            import breezy  # noqa: F401
        except ModuleNotFoundError:
            self.skipTest("breezy is not available")
        self.assertEqual(
            "ssh://github.com/jelmer/example",
            fixup_rcp_style_git_repo_url("github.com:jelmer/example"),
        )
        self.assertEqual(
            "ssh://git@github.com/jelmer/example",
            fixup_rcp_style_git_repo_url("git@github.com:jelmer/example"),
        )

    def test_leave(self):
        try:
            import breezy  # noqa: F401
        except ModuleNotFoundError:
            self.skipTest("breezy is not available")
        self.assertEqual(
            "https://salsa.debian.org/jelmer/example",
            fixup_rcp_style_git_repo_url("https://salsa.debian.org/jelmer/example"),
        )
        self.assertEqual(
            "ssh://git@salsa.debian.org/jelmer/example",
            fixup_rcp_style_git_repo_url("ssh://git@salsa.debian.org/jelmer/example"),
        )