aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2019-10-26 20:49:25 +0200
committerGuido Günther <agx@sigxcpu.org>2019-10-27 11:35:45 +0100
commit0a464d757daec84dcd3cd09d7d59b3ba19376821 (patch)
tree1d1d5170d0c74869b7efa57d67e3c46321f95526
parent49115ded58d8058a513b2d383691a7c81e053e8b (diff)
import_orig: Test prepare_pristine_tar()
-rw-r--r--tests/24_test_gbp_import_orig.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py
index fadff28..0f36820 100644
--- a/tests/24_test_gbp_import_orig.py
+++ b/tests/24_test_gbp_import_orig.py
@@ -8,10 +8,15 @@ from collections import namedtuple
from gbp.scripts.import_orig import (debian_branch_merge_by_replace,
GbpError,
- is_30_quilt)
+ is_30_quilt,
+ prepare_pristine_tar)
+
from gbp.scripts.common.import_orig import download_orig
from . testutils import DebianGitTestRepo
+import shutil
+import tempfile
+
@unittest.skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
class TestImportOrigDownload(DebianGitTestRepo):
@@ -88,3 +93,40 @@ class TestMergeModeReplace(DebianGitTestRepo):
self.assertTrue(os.path.exists("upstream_file"))
# … but upsream's debian dir must not
self.assertFalse(os.path.exists("debian/changelog"))
+
+
+class TestGbpBuildpackagePreparePristineTar(unittest.TestCase):
+ def setUp(self):
+ self._cwd = os.getcwd()
+ self._tmpdir = os.path.abspath(tempfile.mkdtemp(prefix='gbp_', dir='.'))
+ # we need to change into a temp subdir since the link is
+ # create in '..'
+ d = os.path.join(self._tmpdir, 'd')
+ os.mkdir(d)
+ os.chdir(d)
+
+ def tearDown(self):
+ if not os.getenv("GBP_TESTS_NOCLEAN"):
+ shutil.rmtree(self._tmpdir)
+ os.chdir(self._cwd)
+
+ def test_dir(self):
+ ret = prepare_pristine_tar(self._tmpdir, 'foo', '1.0')
+ self.assertEquals(ret, (None, False))
+
+ def test_tar(self):
+ archive = '{}/foo.tgz'.format(self._tmpdir)
+ ret = prepare_pristine_tar(archive, 'foo', '1.0')
+ self.assertEquals(ret, ('../foo_1.0.orig.tar.gz', True))
+ self.assertTrue(os.path.islink(
+ os.path.join(self._tmpdir, 'foo_1.0.orig.tar.gz')))
+
+ def test_signature(self):
+ archive = '{}/foo.tgz'.format(self._tmpdir)
+ signature = '{}.asc'.format(archive)
+ with open(signature, 'w') as f:
+ f.write('')
+ ret = prepare_pristine_tar(archive, 'foo', '1.0')
+ self.assertEquals(ret, ('../foo_1.0.orig.tar.gz', True))
+ self.assertTrue(os.path.islink(
+ os.path.join(self._tmpdir, 'foo_1.0.orig.tar.gz.asc')))