From 5bde44a3c299445c87c677e15f2cf985792bc632 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 5 Nov 2015 20:47:46 +0800 Subject: [PATCH] Add testcases for pacman --- nvchecker/source/pacman.py | 2 +- tests/test_pacman.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test_pacman.py 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/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")