nvchecker/tests/helper.py

22 lines
665 B
Python
Raw Normal View History

import configparser
2015-11-04 13:25:01 +00:00
from tornado.ioloop import IOLoop
2015-11-04 11:14:55 +00:00
import tornado.testing
2015-11-04 13:25:01 +00:00
from nvchecker.get_version import get_version
2015-11-04 11:14:55 +00:00
class ExternalVersionTestCase(tornado.testing.AsyncTestCase):
2015-11-04 13:25:01 +00:00
def get_new_ioloop(self):
return IOLoop.instance()
2015-11-04 11:14:55 +00:00
def sync_get_version(self, name, config):
def get_version_callback(name, version):
2015-11-04 12:50:22 +00:00
self.stop(version)
2015-11-04 11:14:55 +00:00
if isinstance(config, dict):
_config = configparser.ConfigParser(dict_type=dict, allow_no_value=True)
_config.read_dict({name: config})
2015-11-04 15:12:23 +00:00
config = _config[name]
2015-11-04 15:12:23 +00:00
get_version(name, config, get_version_callback)
2015-11-04 12:50:22 +00:00
return self.wait()