aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-01-22 19:45:58 +0100
committerGuido Günther <agx@sigxcpu.org>2012-01-30 16:52:42 +0100
commitc6e70a12bfb4d0f642f7b9db16d7e9ba7db9a976 (patch)
treeca93f4919b94ddc54f0e00e21e394bd91e193b7f /tests
parent3ca0a98125f9599f36fac62b4b075e2e6f27ab5a (diff)
PristineTar: add testcase
Diffstat (limited to 'tests')
-rw-r--r--tests/test_PristineTar.py132
-rw-r--r--tests/test_PristineTar_data/tesfile10
-rw-r--r--tests/test_PristineTar_data/tesfile20
3 files changed, 132 insertions, 0 deletions
diff --git a/tests/test_PristineTar.py b/tests/test_PristineTar.py
new file mode 100644
index 00000000..fe5e6135
--- /dev/null
+++ b/tests/test_PristineTar.py
@@ -0,0 +1,132 @@
+# vim: set fileencoding=utf-8 :
+
+"""
+Test pristine-tar related methods in
+
+ L{gbp.deb.PristineTar}
+
+and
+
+ L{gbp.deb.git.DebianGitRepository}
+
+This testcase creates this reposity:
+
+ - A repository at L{repo_dir} called I{repo}
+
+"""
+
+import os
+tmp_dir = os.path.abspath(
+ os.path.join(os.path.curdir, 'gbp_%s_test' % __name__))
+repo_dir = os.path.join(tmp_dir, 'repo')
+test_data = os.path.abspath("tests/test_PristineTar_data")
+
+def test_create():
+ """
+ Create a repository
+
+ Methods tested:
+ - L{gbp.deb.DebianGitRepository.create}
+
+ >>> import os, gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository.create(repo_dir)
+ """
+
+def test_empty_repo():
+ """
+ Empty repos have no branch pristine-tar branch
+
+ Methods tested:
+ - L{gbp.deb.DebianGitRepository.has_pristine_tar_branch}
+ -L {gbp.deb.PristineTar.has_commit}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> repo.has_pristine_tar_branch()
+ False
+ >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip')
+ False
+ """
+
+def test_commit_dir():
+ """
+ Empty repos have no branch pristine-tar branch
+
+ Methods tested:
+ - L{gbp.git.repository.commit_dir}
+ - L{gbp.git.repository.create_branch}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> commit = repo.commit_dir(test_data, msg="initial commit", branch=None)
+ >>> repo.create_branch('upstream')
+ """
+
+def test_create_tarball():
+ """
+ Create a tarball from a git tree
+
+ Methods tested:
+ -L {gbp.git.repository.archive}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> repo.archive('tar.gz', 'upstream/', '../upstream_1.0.orig.tar.gz', 'upstream')
+ """
+
+def test_pristine_tar_commit():
+ """
+ Commit the delta to the pristine-tar branch
+
+ Methods tested:
+ -L {gbp.deb.PristineTar.commit}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> repo.pristine_tar.commit('../upstream_1.0.orig.tar.gz', 'upstream')
+ """
+
+def test_pristine_has_commit():
+ """
+ Find delta on the pristine tar branch
+
+ Methods tested:
+ -L {gbp.deb.PristineTar.has_commit}
+ -L {gbp.deb.PristineTar.get_commit}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> repo.pristine_tar.has_commit('upstream', '1.0', 'bzip2')
+ False
+ >>> repo.pristine_tar.has_commit('upstream', '1.0', 'gzip')
+ True
+ >>> repo.pristine_tar.has_commit('upstream', '1.0')
+ True
+ >>> branch = repo.rev_parse('pristine-tar')
+ >>> commit = repo.pristine_tar.get_commit('upstream', '1.0')
+ >>> branch == commit
+ True
+ """
+
+def test_pristine_tar_checkout():
+ """
+ Checkout a tarball using pristine-tar
+
+ Methods tested:
+ -L {gbp.deb.PristineTar.checkout}
+
+ >>> import gbp.deb.git
+ >>> repo = gbp.deb.git.DebianGitRepository(repo_dir)
+ >>> repo.pristine_tar.checkout('upstream', '1.0', 'gzip', '..')
+ """
+
+
+def test_teardown():
+ """
+ Perform the teardown
+
+ >>> import shutil, os
+ >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(tmp_dir)
+ """
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/tests/test_PristineTar_data/tesfile1 b/tests/test_PristineTar_data/tesfile1
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/test_PristineTar_data/tesfile1
diff --git a/tests/test_PristineTar_data/tesfile2 b/tests/test_PristineTar_data/tesfile2
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/test_PristineTar_data/tesfile2