From e890ce326ee66e0339ae4c83644473173fc4758e Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 4 Apr 2017 07:13:15 +0200 Subject: ipmort_orig: pick best way to import upstream tarball automatically Add new value --merge-mode=auto that selects either 'replace' or 'merge' depending on the source format version. Closes: #700411 --- tests/24_test_gbp_import_orig.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'tests/24_test_gbp_import_orig.py') diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py index 4264e669..c7619c35 100644 --- a/tests/24_test_gbp_import_orig.py +++ b/tests/24_test_gbp_import_orig.py @@ -4,7 +4,9 @@ import os import unittest -from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError) +from collections import namedtuple + +from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError, is_30_quilt) from gbp.scripts.common.import_orig import download_orig from . testutils import DebianGitTestRepo @@ -69,3 +71,37 @@ class TestImportOrigDownload(DebianGitTestRepo): url = "https://{host}/cgit/gbp/deb-testdata/tree/dsc-3.0/{pkg}".format(host=self.HOST, pkg=pkg) self.assertEqual(download_orig(url).path, '../%s' % pkg) + + +class TestIs30Quilt(DebianGitTestRepo): + Options = namedtuple('Options', 'debian_branch') + format_file = 'debian/source/format' + + def setUp(self): + DebianGitTestRepo.setUp(self) + os.chdir(self.repo.path) + os.makedirs('debian/source/') + + def test_30_quilt(self): + options = self.Options(debian_branch='master') + with open(self.format_file, 'w') as f: + f.write('3.0 (quilt)\n') + self.repo.add_files([self.format_file]) + self.repo.commit_all("Add %s" % self.format_file) + self.assertEquals(self.repo.branch, options.debian_branch) + self.assertTrue(is_30_quilt(self.repo, options)) + + def test_no_format(self): + options = self.Options(debian_branch='master') + self.assertFalse(os.path.exists(self.format_file)) + self.assertFalse(is_30_quilt(self.repo, options)) + + def test_no_quilt(self): + options = self.Options(debian_branch='master') + with open(self.format_file, 'w') as f: + f.write('3.0 (nonexistent)') + self.assertFalse(is_30_quilt(self.repo, options)) + + def test_30_quilt_empty_repo(self): + options = self.Options(debian_branch='master') + self.assertFalse(is_30_quilt(self.repo, options)) -- cgit v1.2.3