From c222197b5dd767578c8777d97316761890083c54 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 7 Aug 2012 18:35:17 +0300 Subject: tests: add test for archiving without git submodules Signed-off-by: Markus Lehtonen --- tests/04_test_submodules.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'tests/04_test_submodules.py') diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index d96d67a..c326f55 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -8,6 +8,7 @@ import os import shutil import tarfile import tempfile +from nose.tools import eq_, ok_ import gbp.log import gbp.git @@ -98,23 +99,29 @@ def test_dump_tree(): assert os.path.exists(os.path.join(dumpdir, submodules[0].name, testfile_name)) -def test_create_tarball(): +def test_create_tarballs(): """Create an upstream tarball""" - cp = { "Source": "test", "Upstream-Version": "0.1" } - assert buildpackage.git_archive(repo, - cp, - str(tmpdir), - "HEAD", - "bzip2", - "9", - True) - -def test_check_tarfile(): + # Tarball with submodules + changelog = { "Source": "test", "Upstream-Version": "0.1" } + ok_(buildpackage.git_archive(repo, changelog, str(tmpdir), "HEAD", "bzip2", + "9", True)) + # Tarball without submodules + changelog = { "Source": "test", "Upstream-Version": "0.2" } + ok_(buildpackage.git_archive(repo, changelog, str(tmpdir), "HEAD", "bzip2", + "9", False)) + +def test_check_tarfiles(): """Check the contents of the created tarfile""" - t = tarfile.open(tmpdir.join("test_0.1.orig.tar.bz2"), 'r:*') - files = t.getmembers() - assert "test-0.1/.gitmodules" in [ f.name for f in files ] - assert len(files) == 6 + # Check tarball with submodules + tarobj = tarfile.open(tmpdir.join("test_0.1.orig.tar.bz2"), 'r:*') + files = tarobj.getmembers() + ok_("test-0.1/.gitmodules" in [ f.name for f in files ]) + eq_(len(files) , 6) + # Check tarball without submodules + tarobj = tarfile.open(tmpdir.join("test_0.2.orig.tar.bz2"), 'r:*') + files = tarobj.getmembers() + ok_(("test-0.2/%s" % testfile_name) in [ f.name for f in files ]) + eq_(len(files) , 4) def test_add_whitespace_submodule(): """Add a second submodule with name containing whitespace""" -- cgit v1.2.3