From c6e70a12bfb4d0f642f7b9db16d7e9ba7db9a976 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 22 Jan 2012 19:45:58 +0100 Subject: PristineTar: add testcase --- tests/test_PristineTar.py | 132 +++++++++++++++++++++++++++++++++++ tests/test_PristineTar_data/tesfile1 | 0 tests/test_PristineTar_data/tesfile2 | 0 3 files changed, 132 insertions(+) create mode 100644 tests/test_PristineTar.py create mode 100644 tests/test_PristineTar_data/tesfile1 create mode 100644 tests/test_PristineTar_data/tesfile2 (limited to 'tests') 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 diff --git a/tests/test_PristineTar_data/tesfile2 b/tests/test_PristineTar_data/tesfile2 new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3