aboutsummaryrefslogtreecommitdiff
path: root/tests/22_test_gbp_buildpackage.py
blob: bbc0e32678c9ea914bbb4f8084b1c4790bbf3e13 (plain)
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
# vim: set fileencoding=utf-8 :
"""Test L{gbp.command_wrappers.Command}'s tarball unpack"""

from gbp.scripts.buildpackage import get_pbuilder_dist, GbpError
from . testutils import DebianGitTestRepo

from mock import patch


class TestGbpBuildpackage(DebianGitTestRepo):
    class Options(object):
        pass

    def setUp(self):
        DebianGitTestRepo.setUp(self)
        self.add_file('doesnotmatter')
        self.options = self.Options()
        self.options.pbuilder_dist = 'DEP14'

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_no_dep14(self, patch):
        self.options.pbuilder_dist = 'notdep14'
        self.assertEqual(get_pbuilder_dist(self.options, self.repo),
                         self.options.pbuilder_dist)

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_debian_sid(self, patch):
        branch = 'debian/sid'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        self.assertEqual(get_pbuilder_dist(self.options, self.repo), '')
        patch.assert_called_once_with()

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_debian_suite(self, patch):
        branch = 'debian/squeeze-lts'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'squeeze-lts')
        patch.assert_called_once_with()

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_debian_native(self, patch):
        self.assertEqual(get_pbuilder_dist(self.options, self.repo, True), '')

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_vendor_sid(self, patch):
        branch = 'downstream/sid'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'downstream_sid')
        patch.assert_called_once_with()

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_vendor_suite(self, patch):
        branch = 'downstream/mies-lts'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'downstream_mies-lts')

    @patch('gbp.deb.get_vendor', return_value='Debian')
    def test_get_pbuilder_dist_dep14_no_vendor(self, patch):
        branch = 'sid'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        with self.assertRaisesRegexp(GbpError,
                                     'DEP14 DIST setup needs branch name to be vendor/suite'):
            get_pbuilder_dist(self.options, self.repo)

    def test_get_pbuilder_dist_dep14_too_many_slashes(self):
        branch = 'too/many/slashed'
        self.repo.create_branch(branch)
        self.repo.set_branch(branch)
        with self.assertRaisesRegexp(GbpError,
                                     'DEP14 DIST setup needs branch name to be vendor/suite'):
            get_pbuilder_dist(self.options, self.repo)