File: test_directory.py

package info (click to toggle)
breezy-debian 2.8.80
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,444 kB
  • sloc: python: 17,599; makefile: 61; sh: 1
file content (111 lines) | stat: -rw-r--r-- 3,896 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
100
101
102
103
104
105
106
107
108
109
110
111
#    test_directory.py -- Testsuite for builddeb directory.py
#    Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
#
#    This file is part of bzr-builddeb.
#
#    bzr-builddeb 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.
#
#    bzr-builddeb 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 bzr-builddeb; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

from ....tests import TestCase

from ..directory import (
    fixup_broken_git_url,
    vcs_git_url_to_bzr_url,
    vcs_hg_url_to_bzr_url,
    vcs_cvs_url_to_bzr_url,
    )


class VcsGitUrlToBzrUrlTests(TestCase):

    def test_preserves(self):
        self.assertEqual(
            'git://github.com/jelmer/dulwich',
            vcs_git_url_to_bzr_url('git://github.com/jelmer/dulwich'))
        self.assertEqual(
            'https://github.com/jelmer/dulwich',
            vcs_git_url_to_bzr_url('https://github.com/jelmer/dulwich'))

    def test_with_branch(self):
        self.assertEqual(
            'https://github.com/jelmer/dulwich,branch=foo',
            vcs_git_url_to_bzr_url('https://github.com/jelmer/dulwich -b foo'))

    def test_with_subpath(self):
        self.assertEqual(
            'https://github.com/jelmer/dulwich/path',
            vcs_git_url_to_bzr_url(
                'https://github.com/jelmer/dulwich [path]'))
        self.assertEqual(
            'https://github.com/jelmer/dulwich,branch=foo/path',
            vcs_git_url_to_bzr_url(
                'https://github.com/jelmer/dulwich -b foo [path]'))

    def test_fixup(self):
        self.assertEqual(
            'git://github.com/jelmer/dulwich',
            vcs_git_url_to_bzr_url('git://github.com:jelmer/dulwich'))


class FixUpGitUrlTests(TestCase):

    def test_salsa_not_https(self):
        self.assertEqual(
            'https://salsa.debian.org/jelmer/dulwich',
            fixup_broken_git_url(
                'git://salsa.debian.org/jelmer/dulwich'))

    def test_salsa_uses_cgit(self):
        self.assertEqual(
            'https://salsa.debian.org/jelmer/dulwich',
            fixup_broken_git_url(
                'https://salsa.debian.org/cgit/jelmer/dulwich'))


class VcsHgUrlToBzrUrlTests(TestCase):

    def test_preserves(self):
        self.assertEqual(
            'https://bitbucket.org/jelmer/dulwich',
            vcs_hg_url_to_bzr_url('https://bitbucket.org/jelmer/dulwich'))

    def test_with_branch(self):
        self.assertEqual(
            'https://bitbucket.org/jelmer/dulwich,branch=foo',
            vcs_hg_url_to_bzr_url(
                'https://bitbucket.org/jelmer/dulwich -b foo'))


class VcsCvsUrlToBzrUrlTests(TestCase):

    def setUp(self):
        super().setUp()
        import breezy
        if breezy.version_info < (3, 1, 1):
            self.skipTest('version of breezy too old')

    def test_pserver(self):
        self.assertEqual(
            'cvs+pserver://anonymous@cvs.savannah.nongnu.org'
            '/cvsroot/fkt?module=debian/unstable',
            vcs_cvs_url_to_bzr_url(
                ':pserver:anonymous@cvs.savannah.nongnu.org:'
                '/cvsroot/fkt debian/unstable'))
        self.assertEqual(
            'cvs+pserver://anonymous@cvs.savannah.nongnu.org'
            '/cvsroot/fkt',
            vcs_cvs_url_to_bzr_url(
                ':pserver:anonymous@cvs.savannah.nongnu.org:'
                '/cvsroot/fkt'))