summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLoïc Minier <lool@debian.org>2011-04-08 03:32:17 +0200
committerGuido Günther <agx@sigxcpu.org>2011-04-09 22:40:08 +0200
commit8189cc9e01ed42f67b20d59a9f18247779a86ed4 (patch)
tree426d36800e60f35ff1364c702f2867a581e7de28 /tests
parent2d620e42da219d7e8d03f8948de903d87f89b2f2 (diff)
downloadgit-buildpackage-8189cc9e01ed42f67b20d59a9f18247779a86ed4.tar.gz
git-buildpackage-8189cc9e01ed42f67b20d59a9f18247779a86ed4.tar.bz2
git-buildpackage-8189cc9e01ed42f67b20d59a9f18247779a86ed4.zip
Add tests for orig autodetection
Diffstat (limited to 'tests')
-rw-r--r--tests/05_test_detection.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
new file mode 100644
index 00000000..1454e4da
--- /dev/null
+++ b/tests/05_test_detection.py
@@ -0,0 +1,50 @@
+import os
+import shutil
+import tempfile
+import unittest
+
+import git_buildpackage
+from gbp.deb import has_orig
+
+class MockGitRepository:
+ def __init__(self, with_branch=False, subject=None):
+ self.with_branch = with_branch
+ self.subject = subject
+
+ def has_branch(self, branch):
+ return self.with_branch
+
+ def grep_log(self, regex, branch):
+ return None
+
+ def get_subject(self, commit):
+ return self.subject
+
+class TestDetection(unittest.TestCase):
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.tmpdir)
+
+ def test_guess_comp_type_no_pristine_tar(self):
+ repo = MockGitRepository(with_branch=False)
+ guessed = git_buildpackage.guess_comp_type(repo, 'auto', None, None)
+ self.assertEqual('gzip', guessed)
+
+ def test_guess_comp_type_bzip2(self):
+ subject = 'pristine-tar data for source_1.2-3.orig.tar.bz2'
+ repo = MockGitRepository(with_branch=True, subject=subject)
+ guessed = git_buildpackage.guess_comp_type(
+ repo, 'auto', 'source', '1.2')
+ self.assertEqual("bzip2", guessed)
+
+ def test_has_orig_false(self):
+ cp = {'Source': 'source', 'Upstream-Version': '1.2'}
+ self.assertFalse(has_orig(cp, 'gzip', self.tmpdir))
+
+ def test_has_orig_true(self):
+ cp = {'Source': 'source', 'Upstream-Version': '1.2'}
+ open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.gz'), "w").close()
+ self.assertTrue(has_orig(cp, 'gzip', self.tmpdir))
+