diff --git a/nvchecker/source/pacman.py b/nvchecker/source/pacman.py index b9c43b3..baf12f8 100644 --- a/nvchecker/source/pacman.py +++ b/nvchecker/source/pacman.py @@ -1,7 +1,7 @@ from . import cmd def get_version(name, conf, callback): - referree = conf['pacman'] + referree = conf.get('pacman') or name c = "LANG=C pacman -Si %s | grep -F Version | awk '{print $3}'" % referree conf['cmd'] = c diff --git a/nvchecker/source/vcs.py b/nvchecker/source/vcs.py index 75e5e4a..b2481f7 100644 --- a/nvchecker/source/vcs.py +++ b/nvchecker/source/vcs.py @@ -27,7 +27,7 @@ def _parse_oldver(oldver): def get_version(name, conf, callback): vcs = conf['vcs'] - oldver = conf['oldver'] + oldver = conf.get('oldver') cmd = _cmd_prefix + [name, vcs] p = tornado.process.Subprocess(cmd, io_loop=IOLoop.instance(), stdout=tornado.process.Subprocess.STREAM) diff --git a/tests/test_gitcafe.py b/tests/test_gitcafe.py new file mode 100644 index 0000000..2d74a93 --- /dev/null +++ b/tests/test_gitcafe.py @@ -0,0 +1,6 @@ +from tests.helper import ExternalVersionTestCase + + +class GitCafeTest(ExternalVersionTestCase): + def test_gitcafe(self): + self.assertEqual(self.sync_get_version("example", {"gitcafe": "test/test"}), "20120201") diff --git a/tests/test_pacman.py b/tests/test_pacman.py new file mode 100644 index 0000000..62b8d2e --- /dev/null +++ b/tests/test_pacman.py @@ -0,0 +1,13 @@ +import shutil +import pytest +from tests.helper import ExternalVersionTestCase + + +@pytest.mark.skipif(shutil.which("pacman") is None, + reason="requires pacman command") +class PacmanTest(ExternalVersionTestCase): + def test_pacman(self): + self.assertEqual(self.sync_get_version("ipw2100-fw", {"pacman": None}), "1.3-7") + + def test_pacman_strip_release(self): + self.assertEqual(self.sync_get_version("ipw2100-fw", {"pacman": None, "strip-release": 1}), "1.3") diff --git a/tests/test_vcs.py b/tests/test_vcs.py new file mode 100644 index 0000000..092f22b --- /dev/null +++ b/tests/test_vcs.py @@ -0,0 +1,18 @@ +import os +import shutil +import pytest +from tests.helper import ExternalVersionTestCase + + +class VCSTest(ExternalVersionTestCase): + @pytest.mark.skipif(shutil.which("git") is None, + reason="requires git command") + def test_git(self): + os.path.exists("example") or os.mkdir("example") + self.assertEqual(self.sync_get_version("example", {"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git"}), "1.1.2b3cdf6134b07ae6ac77f11b586dc1ae6d1521db") + + @pytest.mark.skipif(shutil.which("hg") is None, + reason="requires hg command") + def test_mercurial(self): + os.path.exists("example") or os.mkdir("example") + self.assertEqual(self.sync_get_version("example", {"vcs": "hg+https://bitbucket.org/pil0t/testrepo"}), "1.1.84679e29c7d9")