From 5db3b93dcdbf2773f24f36ed3a28df38ebd8c6bb Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Wed, 4 Nov 2015 23:11:59 +0800 Subject: [PATCH 1/2] test helper: generate a real ConfigParser to make all its methods available --- tests/helper.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/helper.py b/tests/helper.py index 9f0358f..280e72c 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,3 +1,4 @@ +import configparser from tornado.ioloop import IOLoop import tornado.testing from nvchecker.get_version import get_version @@ -11,5 +12,12 @@ class ExternalVersionTestCase(tornado.testing.AsyncTestCase): def get_version_callback(name, version): self.stop(version) - get_version(name, config, get_version_callback) + if isinstance(config, dict): + _config = configparser.ConfigParser(dict_type=dict, allow_no_value=True) + _config.read_dict({name: config}) + _config = _config[name] + else: + _config = config + + get_version(name, _config, get_version_callback) return self.wait() From 0047c6ddac43ed9603b7866e7b112f64bc3dd46e Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Wed, 4 Nov 2015 23:12:23 +0800 Subject: [PATCH 2/2] add testcases for AUR --- tests/helper.py | 6 ++---- tests/test_aur.py | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tests/test_aur.py diff --git a/tests/helper.py b/tests/helper.py index 280e72c..3e45361 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -15,9 +15,7 @@ class ExternalVersionTestCase(tornado.testing.AsyncTestCase): if isinstance(config, dict): _config = configparser.ConfigParser(dict_type=dict, allow_no_value=True) _config.read_dict({name: config}) - _config = _config[name] - else: - _config = config + config = _config[name] - get_version(name, _config, get_version_callback) + get_version(name, config, get_version_callback) return self.wait() diff --git a/tests/test_aur.py b/tests/test_aur.py new file mode 100644 index 0000000..6559ad3 --- /dev/null +++ b/tests/test_aur.py @@ -0,0 +1,9 @@ +from tests.helper import ExternalVersionTestCase + + +class AURTest(ExternalVersionTestCase): + def test_aur(self): + self.assertEqual(self.sync_get_version("asciidoc-fake", {"aur": None}), "1.0-1") + + def test_aur_strip_release(self): + self.assertEqual(self.sync_get_version("asciidoc-fake", {"aur": None, "strip-release": 1}), "1.0")