diff --git a/tests/packagetests.py b/tests/packagetests.py new file mode 100644 index 00000000..873e725f --- /dev/null +++ b/tests/packagetests.py @@ -0,0 +1,40 @@ + +import unittest +import os + +from pisi import util +from pisi.config import config +from pisi import package + + +class PackageTestCase(unittest.TestCase): + + def setUp(self): + self.pkgName = util.package_name("testing", + "5.1", + "2") + + def testAddExtract(self): + cur = os.getcwd() + tmpdir = config.tmp_dir() + sandboxdir = os.path.join(cur, "tests/sandbox") + + pkg_path = os.path.join(tmpdir, self.pkgName) + pkg = package.Package(pkg_path, "w") + + os.chdir(sandboxdir) + pkg.add_to_package("files.xml") + pkg.add_to_package("metadata.xml") + os.chdir(cur) + + pkg.close() + + pkg = package.Package(pkg_path) + pkg.extract_file("files.xml", cur) + if not os.path.exists("files.xml"): + self.fail("Package extract error") + + os.remove("files.xml") + os.remove(pkg_path) + +suite = unittest.makeSuite(PackageTestCase) diff --git a/tests/run.py b/tests/run.py index 1b9aa60a..c49c9e23 100755 --- a/tests/run.py +++ b/tests/run.py @@ -23,6 +23,7 @@ def run_all(): import graphtests import versiontests import configfiletests + import packagetests alltests = unittest.TestSuite(( utiltests.suite, @@ -38,7 +39,8 @@ def run_all(): actionsapitests.suite, graphtests.suite, versiontests.suite, - configfiletests.suite + configfiletests.suite, + packagetests.suite )) runTestSuite(alltests)