From b21da2212c063b3859a12c9b96c9a35605f54aa6 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 15 Nov 2009 13:04:07 +0000 Subject: [PATCH] Get test data through Zero Install Also, fixed a bug finding the RPM primary file (should be relative to the repomd file, not relative to the current directory). --- pkg2zero | 3 ++- pkg2zero.xml | 3 +++ tests/testall.py | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg2zero b/pkg2zero index a0427e0..938730c 100755 --- a/pkg2zero +++ b/pkg2zero @@ -205,10 +205,11 @@ class RPMRepo: def get_repo_metadata(self, pkg_name): primary_file = None repomd = minidom.parse(self.repomd_file) + repo_top = os.path.dirname(os.path.dirname(self.repomd_file)) for data in repomd.getElementsByTagName("data"): if data.attributes["type"].nodeValue == "primary": for node in data.getElementsByTagName("location"): - primary_file = node.attributes["href"].nodeValue + primary_file = os.path.join(repo_top, node.attributes["href"].nodeValue) location = None primary = ET.parse(gzip.open(primary_file)) NS = "http://linux.duke.edu/metadata/common" diff --git a/pkg2zero.xml b/pkg2zero.xml index 2533557..8380860 100644 --- a/pkg2zero.xml +++ b/pkg2zero.xml @@ -25,6 +25,9 @@ in an existing package and uses it to generate the feed. + + + diff --git a/tests/testall.py b/tests/testall.py index 705658d..31e80c5 100755 --- a/tests/testall.py +++ b/tests/testall.py @@ -12,6 +12,10 @@ def run(args): child = subprocess.Popen([pkg2zero] + args, stdout = subprocess.PIPE, stderr = subprocess.PIPE, stdin = subprocess.PIPE) return child.communicate("\n\n") +TEST_DATA = os.environ["TEST_DATA"] +def testdata(path): + return os.path.join(TEST_DATA, path) + class TestAll(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp('pkg2zero') @@ -42,7 +46,7 @@ class TestAll(unittest.TestCase): def testRPM(self): target = os.path.join(self.tmpdir, 'time.xml') - cout, cerr = run(["http://mirror.centos.org/centos/5/os/i386/CentOS/time-1.7-27.2.2.i386.rpm", target]) + cout, cerr = run(['-r', testdata('repodata/repomd.xml'), "http://mirror.centos.org/centos/5/os/i386/CentOS/time-1.7-27.2.2.i386.rpm", target]) assert 'Added version 1.7 to ' in cout, (cout, cerr) assert 'Mappings file not found' in cerr assert 'no SHA-1' in cerr @@ -54,7 +58,7 @@ class TestAll(unittest.TestCase): def testRepoDeb(self): target = os.path.join(self.tmpdir, 'netcat.xml') - cout, cerr = run(["netcat-traditional", '--packages-file', 'Packages.bz2', target]) + cout, cerr = run(["netcat-traditional", '--packages-file', testdata('Packages.bz2'), target]) assert 'Added version 1.10-38 to ' in cout, (cout, cerr) assert 'Mappings file not found' in cerr assert "Package's digest matches value in reposistory metadata" in cout, (cout, cerr) @@ -67,7 +71,7 @@ class TestAll(unittest.TestCase): def testRepoRPM(self): target = os.path.join(self.tmpdir, 'time.xml') - cout, cerr = run(["time", '--repomd-file', 'repodata/repomd.xml', target]) + cout, cerr = run(["time", '--repomd-file', testdata('repodata/repomd.xml'), target]) assert 'Added version 1.7 to ' in cout, (cout, cerr) assert 'Mappings file not found' in cerr assert "Package's digest matches value in reposistory metadata" in cout, (cout, cerr) -- 2.11.4.GIT