diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-11-23 18:26:02 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-11-23 19:24:12 +0100 |
commit | d248720ff924801d8e3de6291d3b2e512169a3ca (patch) | |
tree | f292ce599e16263574ebc8be1384d05937b70695 /tests | |
parent | 691856db3c97499e07a8ddaf886eb75a17b6046d (diff) |
Test apply_and_commit_patch
Diffstat (limited to 'tests')
-rw-r--r-- | tests/13_test_gbp_pq.py | 57 | ||||
-rw-r--r-- | tests/data/foo.patch | 12 |
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py new file mode 100644 index 0000000..9fba870 --- /dev/null +++ b/tests/13_test_gbp_pq.py @@ -0,0 +1,57 @@ +# vim: set fileencoding=utf-8 : + +"""Test L{gbp.pq}""" + +import os +import unittest + +import gbp.scripts.common.pq +import gbp.patch_series +import tests.testutils as testutils + +class TestApplyAndCommit(testutils.DebianGitTestRepo): + """Test L{gbp.pq}'s apply_and_commit""" + + def setUp(self): + testutils.DebianGitTestRepo.setUp(self) + self.add_file('bar') + + def test_apply_and_commit_patch(self): + """Test applying a single patch""" + patch = gbp.patch_series.Patch( + os.path.join(os.path.abspath(os.path.curdir), + 'tests/data/foo.patch')) + + gbp.scripts.common.pq.apply_and_commit_patch(self.repo, patch) + self.assertIn('foo', self.repo.list_files()) + + @unittest.skipIf(not os.path.exists('/usr/bin/dpkg'), 'Dpkg not found') + def test_debian_missing_author(self): + """ + Check if we parse the author from debian control + if it's missing. + """ + patch = gbp.patch_series.Patch( + os.path.join(os.path.abspath(os.path.curdir), + 'tests/data/foo.patch')) + + # Overwrite data parsed from patch: + patch.author + patch.info['author'] = None + patch.info['email'] = None + + # Fake a control file + self.add_file("debian/control", + "Maintainer: Guido Günther <gg@godiug.net>") + + gbp.scripts.common.pq.apply_and_commit_patch(self.repo, patch) + info = self.repo.get_commit_info('HEAD') + self.assertEqual(info['author'].email, 'gg@godiug.net') + self.assertIn('foo', self.repo.list_files()) + + + + + + + diff --git a/tests/data/foo.patch b/tests/data/foo.patch new file mode 100644 index 0000000..c4d0b60 --- /dev/null +++ b/tests/data/foo.patch @@ -0,0 +1,12 @@ +From: Guido Günther <agx@sigxcpu.org> +Subject: foobar + + foo + +diff --git a/foo b/foo +new file mode 100644 +index 0000000..257cc56 +--- /dev/null ++++ b/foo +@@ -0,0 +1 @@ ++foo |