# Prevent use of a first line from test docstring as its name in output
self.shortDescription_orig = self.shortDescription
self.shortDescription = self._shortDescription
+ self.main_cwd = os.getcwd()
def _shortDescription(self):
return ".".join(self.id().split('.')[-2:])
unittest.TestCase.run(self, result)
def setUp(self):
+ os.chdir(self.main_cwd) # In case of TimedOutException in Nose test... the tearDown is not called :-/
caller = self.id().split(".", 3)[-1]
self.tdir = os.path.abspath(os.path.join(self.tcdir, caller))
os.mkdir(self.tdir)
fn = os.path.join(self.tdir, "description")
open(fn, "w").write(description+'\n')
#self.log = # TODO
- self.main_cwd = os.getcwd()
os.chdir(self.tdir)
self.setup()
def runcmd(self, cmd, logfile=None, workdir=None, stdin_data=None):
"""Stolen from the kobo library.
Author of the original function is dmach@redhat.com"""
+
+ # TODO: Add time how long the command takes
+
if type(cmd) in (list, tuple):
import pipes
cmd = " ".join(pipes.quote(i) for i in cmd)
if logfile is not None:
+ already_exists = False
+ if os.path.exists(logfile):
+ already_exists = True
logfile = open(logfile, "a")
+ if already_exists:
+ logfile.write("\n{0}\n Another run\n{0}\n".format('='*79))
logfile.write("cd %s\n" % os.getcwd())
for var in ("PATH", "PYTHONPATH", "LD_LIBRARY_PATH"):
logfile.write('export %s="%s"\n' % (var, os.environ.get(var,"")))
res.outdir = os.path.join(self.tdir, res.prog)
else:
res.outdir = os.path.join(self.tdir, outdir)
- os.mkdir(res.outdir)
+ if not os.path.exists(res.outdir):
+ os.mkdir(res.outdir)
res.logfile = os.path.join(self.tdir, "out_%s" % res.prog)
res.cmd = "%(prog)s --verbose -o %(outdir)s %(args)s %(dir)s" % {
"prog": res.prog,
--- /dev/null
+import os
+import os.path
+
+from fixtures import PACKAGES
+from base import BaseTestCase
+
+
+class TestCaseCreaterepoUpdateComparative_emptyrepo(BaseTestCase):
+ """Empty input repository"""
+
+ def test_01_createrepoupdate(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir)
+ self.assert_same_results(self.indir, "--update")
+
+ def test_02_createrepoupdate_double(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir)
+ self.assert_same_results(self.indir, "--update")
+ self.assert_same_results(self.indir, "--update")
+
+ def test_03_createrepoupdate_relativepath(self):
+ """Repo from empty directory - specified by relative path"""
+ self.assert_same_results(os.path.relpath(self.indir))
+ self.assert_same_results(os.path.relpath(self.indir), "--update")
+
+ def test_04_createrepoupdate_simplemdfilenames(self):
+ """Repo from empty directory - specified by relative path"""
+ self.assert_same_results(os.path.relpath(self.indir))
+ self.assert_same_results(os.path.relpath(self.indir), "--update --simple-md-filenames")
+
+
+class TestCaseCreaterepoUpdateComparative_regularrepo(BaseTestCase):
+ """Repo with 3 packages"""
+
+ def setup(self):
+ self.indir_addpkg(PACKAGES[0])
+ self.indir_addpkg(PACKAGES[1])
+ self.indir_addpkg(PACKAGES[2])
+
+ def test_01_createrepoupdate(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir)
+ self.assert_same_results(self.indir, "--update")
+
+ def test_02_createrepoupdate_double(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir)
+ self.assert_same_results(self.indir, "--update")
+ self.assert_same_results(self.indir, "--update")
+
+ def test_03_createrepoupdate_relativepath(self):
+ """Repo from empty directory - specified by relative path"""
+ self.assert_same_results(os.path.relpath(self.indir))
+ self.assert_same_results(os.path.relpath(self.indir), "--update")
+
+ def test_04_createrepoupdate_simplemdfilenames(self):
+ """Repo from empty directory - specified by relative path"""
+ self.assert_same_results(os.path.relpath(self.indir))
+ self.assert_same_results(os.path.relpath(self.indir), "--update --simple-md-filenames")
+
+
+class TestCaseCreaterepoUpdateComparative_regularrepoandupdaterepo(BaseTestCase):
+ """Repo with 3 packages and repo that will be used as --update-md-path"""
+
+ def setup(self):
+ self.indir_addpkg(PACKAGES[0])
+ self.indir_addpkg(PACKAGES[1])
+ self.indir_addpkg(PACKAGES[2])
+ res = self.assert_run_cr(self.indir)
+ self.update_md_path = os.path.join(self.tdir, "update_md_path")
+ os.rename(res.outdir, self.update_md_path)
+ os.rename(res.logfile, os.path.join(self.tdir, "out_createrepo-update_md_path"))
+
+ def test_01_createrepoupdate_updatemdpath(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir, "--update --update-md-path %s" % self.update_md_path)
+
+ def test_02_createrepoupdate_updatemdpathandupdate(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir, "--update --update-md-path %s" % self.update_md_path)
+ self.assert_same_results(self.indir, "--update")
+
+ def test_03_createrepoupdate_updatemdpathdouble(self):
+ """Repo from empty directory"""
+ self.assert_same_results(self.indir, "--update --update-md-path %s" % self.update_md_path)
+ self.assert_same_results(self.indir, "--update --update-md-path %s" % self.update_md_path)
\ No newline at end of file