diff options
author | Tomas Mlcoch <tmlcoch@redhat.com> | 2014-06-04 16:48:15 +0400 |
---|---|---|
committer | Tomas Mlcoch <tmlcoch@redhat.com> | 2014-06-04 18:42:48 +0400 |
commit | 78d82d9e758886afb398559b08fc5de570a43909 (patch) | |
tree | 168cd85c6d44569f7eea912be3af585ee1ba5af1 | |
parent | 9ae853c3003e69f449edf4edb513646bf1bd8822 (diff) |
Acceptance tests: New tests
-rwxr-xr-x | acceptance_tests/run_nosetests.sh | 2 | ||||
-rw-r--r-- | acceptance_tests/tests/base.py | 14 | ||||
-rw-r--r-- | acceptance_tests/tests/test_createrepo_update_comparative.py | 87 |
3 files changed, 100 insertions, 3 deletions
diff --git a/acceptance_tests/run_nosetests.sh b/acceptance_tests/run_nosetests.sh index 18eaa51..454e476 100755 --- a/acceptance_tests/run_nosetests.sh +++ b/acceptance_tests/run_nosetests.sh @@ -3,7 +3,7 @@ CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BUILDDIR="$( cd "$CURDIR/../build" && pwd )" -PATH="$BUILDDIR/src/:/home/tmlcoch/git/repodiff/:$PATH" LD_LIBRARY_PATH=$BUILDDIR/src/ PYTHONPATH=$BUILDDIR/src/python/ nosetests -s -v ./tests/ --processes 4 --process-timeout=60 +PATH="$BUILDDIR/src/:/home/tmlcoch/git/repodiff/:$PATH" LD_LIBRARY_PATH=$BUILDDIR/src/ PYTHONPATH=$BUILDDIR/src/python/ nosetests -s -v ./tests/ --processes 4 --process-timeout=90 # Single test: # PATH="$BUILDDIR/src/:/home/tmlcoch/git/repodiff/:$PATH" LD_LIBRARY_PATH=$BUILDDIR/src/ PYTHONPATH=$BUILDDIR/src/python/ nosetests -s -v --processes 4 --process-timeout=60 tests/test_createrepo.py:TestCaseCreaterepo_emptyrepo.test_01_createrepo diff --git a/acceptance_tests/tests/base.py b/acceptance_tests/tests/base.py index 236458d..2bd4f11 100644 --- a/acceptance_tests/tests/base.py +++ b/acceptance_tests/tests/base.py @@ -70,6 +70,7 @@ class BaseTestCase(unittest.TestCase): # 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:]) @@ -80,6 +81,7 @@ class BaseTestCase(unittest.TestCase): 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) @@ -90,7 +92,6 @@ class BaseTestCase(unittest.TestCase): 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() @@ -110,12 +111,20 @@ class BaseTestCase(unittest.TestCase): 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,""))) @@ -192,7 +201,8 @@ class BaseTestCase(unittest.TestCase): 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, diff --git a/acceptance_tests/tests/test_createrepo_update_comparative.py b/acceptance_tests/tests/test_createrepo_update_comparative.py new file mode 100644 index 0000000..4867d41 --- /dev/null +++ b/acceptance_tests/tests/test_createrepo_update_comparative.py @@ -0,0 +1,87 @@ +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 |