File: test_import_ref.py

package info (click to toggle)
git-buildpackage 0.9.39
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,464 kB
  • sloc: python: 18,427; xml: 8,746; sh: 731; makefile: 139
file content (99 lines) | stat: -rw-r--r-- 3,439 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
# vim: set fileencoding=utf-8 :
#
# (C) 2015,2017 Guido Günther <agx@sigxcpu.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, please see
#    <http://www.gnu.org/licenses/>

import os

from tests.component import ComponentTestBase
from tests.component.deb import DEB_TEST_DATA_DIR
from tests.component.deb.fixtures import RepoFixtures

from gbp.scripts.import_ref import main as import_ref


def _dsc_file(pkg, version, dir='dsc-3.0'):
    return os.path.join(DEB_TEST_DATA_DIR, dir, '%s_%s.dsc' % (pkg, version))


DEFAULT_DSC = _dsc_file('hello-debhelper', '2.6-2')


class TestImportRef(ComponentTestBase):
    """Test importing of new upstream versions"""
    pkg = "hello-debhelper"
    def_branches = ['master', 'upstream', 'pristine-tar']

    def _orig(self, version, dir='dsc-3.0'):
        return os.path.join(DEB_TEST_DATA_DIR,
                            dir,
                            '%s_%s.orig.tar.gz' % (self.pkg, version))

    @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar'])
    def test_from_branch(self, repo):
        """
        Test that importing a upstream git from a branch works
        """
        assert len(repo.get_commits()) == 2
        assert (
            import_ref(
                [
                    "arg0",
                    "--upstream-tree=BRANCH",
                    "--upstream-tag=theupstream/%(version)s",
                    "-uaversion",
                ]
            ) == 0
        )
        self._check_repo_state(
            repo,
            "master",
            self.def_branches,
            tags=["debian/2.6-2", "theupstream/aversion", "upstream/2.6"],
        )
        assert len(repo.get_commits()) == 3

    @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar'])
    def test_from_version(self, repo):
        """
        Test that importing a upstream git from a given version works
        """
        assert len(repo.get_commits()) == 2
        assert (
            import_ref(
                ["arg0", "--upstream-tree=VERSION", "--upstream-tag=upstream/%(version)s", "-u2.6"]
            ) == 0
        )
        self._check_repo_state(
            repo, "master", self.def_branches, tags=["debian/2.6-2", "upstream/2.6"]
        )
        assert len(repo.get_commits()) == 3

    @RepoFixtures.quilt30(DEFAULT_DSC, opts=['--pristine-tar'])
    def test_from_commitish(self, repo):
        """
        Test that importing a upstream git from another commit works
        """
        assert len(repo.get_commits()) == 2
        assert (
            import_ref(
                ["arg0", "--upstream-tree=upstream", "--upstream-tag=upstream/%(version)s", "-u2.6"]
            ) == 0
        )
        self._check_repo_state(
            repo, "master", self.def_branches, tags=["debian/2.6-2", "upstream/2.6"]
        )
        assert len(repo.get_commits()) == 3