aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-03-18 19:42:38 +0100
committerGuido Günther <agx@sigxcpu.org>2011-03-19 18:17:08 +0100
commit80048e9ae3dcc0c7e8443715761dbf5cf21b6f0d (patch)
tree14516071cbcdd5cbf02fec6c97a3ec0b180ec0de /tests
parent7e0a3ade885735cbb34c0f5f7967759fcaba8f62 (diff)
tests: Add testcase for dump_archive()
Diffstat (limited to 'tests')
-rw-r--r--tests/04_test_gbp_submodules.py62
1 files changed, 38 insertions, 24 deletions
diff --git a/tests/04_test_gbp_submodules.py b/tests/04_test_gbp_submodules.py
index c48cac45..f24861a9 100644
--- a/tests/04_test_gbp_submodules.py
+++ b/tests/04_test_gbp_submodules.py
@@ -7,35 +7,40 @@ import tempfile
import gbp.git
import gbp.command_wrappers
+import git_buildpackage
+
top = None
repo = None
-repo_dir = None
+repodir = None
submodule = None
-submodule_dir = None
+submoduledir = None
+submodule_name = "test_submodule"
+
+tmpdir = None
+testfile_name = "testfile"
+
def setup():
- global repo, repo_dir, submodule, submodule_dir, top
+ global repo, repodir, submodule, submoduledir, top, tmpdir
top = os.path.abspath(os.curdir)
+ tmpdir =os.path.join(top,'gbp_%s_repo' % __name__)
+ os.mkdir(tmpdir)
- repo_dir = os.path.join(top, 'gbp_%s_repo' % __name__)
- repo = gbp.git.create_repo(repo_dir)
+ repodir = os.path.join(tmpdir, 'test_repo')
+ repo = gbp.git.create_repo(repodir)
- submodule_dir = os.path.join(top, 'gbp_%s_submodule' % __name__)
- submodule = gbp.git.create_repo(submodule_dir)
-
- os.chdir(repo_dir)
+ submoduledir = os.path.join(tmpdir, submodule_name)
+ submodule = gbp.git.create_repo(submoduledir)
+ os.chdir(repodir)
def teardown():
os.chdir(top)
- if not os.getenv("GBP_TESTS_NOCLEAN"):
- if repo_dir:
- shutil.rmtree(repo_dir)
- if submodule_dir:
- shutil.rmtree(submodule_dir)
+ if not os.getenv("GBP_TESTS_NOCLEAN") and tmpdir:
+ shutil.rmtree(tmpdir)
def test_empty_has_submodules():
@@ -43,31 +48,31 @@ def test_empty_has_submodules():
assert not repo.has_submodules()
-def _add_dummy_data():
- shutil.copy(".git/HEAD", "testfile")
+def _add_dummy_data(msg):
+ shutil.copy(".git/HEAD", testfile_name)
gbp.command_wrappers.GitAdd()(['-f', '.'])
- gbp.command_wrappers.GitCommand("commit", ["-mfoo", "-a"])()
+ gbp.command_wrappers.GitCommand("commit", ["-m%s" % msg, "-a"])()
def test_add_files():
"""Add some dummy data"""
- _add_dummy_data()
+ _add_dummy_data("initial commit")
assert True
def test_add_submodule_files():
"""Add some dummy data"""
- os.chdir(submodule_dir)
- _add_dummy_data()
- os.chdir(repo_dir)
+ os.chdir(submoduledir)
+ _add_dummy_data("initial commit in submodule")
+ os.chdir(repodir)
assert True
def test_add_submodule():
"""Add a submodule"""
- repo.add_submodule(submodule_dir)
+ repo.add_submodule(submoduledir)
gbp.command_wrappers.GitCommand("commit",
- ["-m 'Added submodule %s'" % submodule_dir,
+ ["-m 'Added submodule %s'" % submoduledir,
"-a"])()
def test_has_submodules():
@@ -78,7 +83,16 @@ def test_has_submodules():
def test_get_submodules():
"""Check for submodules list of (name, hash)"""
submodule = repo.get_submodules("master")[0]
- assert submodule[0] == './gbp_04_test_gbp_submodules_submodule'
+ assert submodule[0] == './test_submodule'
assert len(submodule[1]) == 40
+def test_dump_tree():
+ """Dump the repository and check if files exist"""
+ dumpdir = os.path.join(tmpdir, "dump")
+ os.mkdir(dumpdir)
+ assert git_buildpackage.dump_tree(repo, dumpdir, "master")
+ assert os.path.exists(os.path.join(dumpdir, testfile_name))
+ assert os.path.exists(os.path.join(dumpdir, submodule_name, testfile_name))
+
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: