def __call__(self): """ @rtype: C{ots.server.hub.options.Options} @return: The Options """ if not self.core_options_dict.has_key("image"): raise ValueError("Missing `image` parameter") LOG.debug("Calling options with kwarg: %s" % (Options.format_dict(self.core_options_dict))) return Options(**self.processed_core_options_dict)
def __init__(self, sw_product, request_id, **kwargs): """ The kwargs are the dictionary of arguments provided by the request. Note. That these must contain an 'image' @type sw_product: C{str} @param sw_product: Name of the sw product this testrun belongs to @type request_id: C{str} @param request_id: An identifier for the request from the client """ sandbox.is_on = True self._sw_product = sw_product self._request_id = request_id self._testrun_uuid = None self._options_factory = OptionsFactory(self.sw_product, kwargs) self._taskrunner = None self._options = None self._filehandler = None self._initialize_logger() LOG.debug(Options.format_dict(self._options_factory.all_options_dict)) self._publishers = Publishers(self.request_id, self.testrun_uuid, self.sw_product, **self._options_factory.all_options_dict) LOG.debug("Publishers initilialised... sandbox switched off...") LOG.info("OTS Server. version '%s'" % (__VERSION__)) # Log incoming options to help testrun debugging. # These need to match the xmlrpc interface options! try: incoming_options = deepcopy(kwargs) notify_list = "" if "notify_list" in incoming_options.keys(): notify_list = incoming_options["notify_list"] del incoming_options["notify_list"] incoming_options = Options.format_dict(incoming_options) LOG.info(("Incoming request: program: %s, request: %s, " \ "notify_list: %s, options: %s")\ % (sw_product, request_id, notify_list, incoming_options)) # Send first monitor event send_monitor_event(MonitorType.TESTRUN_REQUESTED, __name__) except ValueError: pass
def test_host_packages(self): kwargs = {"image": "www.nokia.com", "distribution_model": "default"} options = Options(**kwargs) self.assertEquals([], options.host_packages) kwargs = { "image": "www.nokia.com", "distribution_model": "default", "hosttest": "pkg_1-tests pkg_2-tests pkg_3-tests" } options = Options(**kwargs) self.assertEquals(["pkg_1-tests", "pkg_2-tests", "pkg_3-tests"], options.host_packages)
def test_resume(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "resume": True } options = Options(**kwargs) self.assertEquals(True, options.resume)
def test_libssh2(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "use_libssh2": True } options = Options(**kwargs) self.assertEquals(True, options.use_libssh2)
def test_flasher(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "flasher": "www.meego.com" } options = Options(**kwargs) self.assertEquals("www.meego.com", options.flasher)
def test_distribution_model(self): kwargs = { "image": "www.nokia.com", "distribution_model": "perpackage", "packages": "asdf-tests" } options = Options(**kwargs) self.assertEquals("perpackage", options.distribution_model)
def test_emmc(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "emmc": "foo" } options = Options(**kwargs) self.assertEquals("foo", options.emmc)
def test_host_testplans(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "host_testplans": [["plan1", "foo"], ["plan2", "bar"]] } options = Options(**kwargs) self.assertEquals(len(options.host_testplans), 2) self.assertTrue(isinstance(options.host_testplans[0], StringIO))
def test_rootstrap(self): options = Options( **{ "image": "www.nokia.com", "distribution_model": "default", "rootstrap": "www.meego.com", "chroottest": "pkg_1-tests pkg_2-tests pkg_3-tests" }) self.assertEquals("www.meego.com", options.rootstrap)
def test_testfilter(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "testfilter": '"hello world"' } options = Options(**kwargs) self.assertEquals('\'"\\\'hello world\\\'"\'', repr(options.testfilter))
def test_hw_packages(self): kwargs = { "image": "www.nokia.com", "distribution_model": "default", "packages": "pkg_1 pkg_2 pkg_3" } self.assertRaises(ValueError, Options, **kwargs) kwargs = { "image": "www.nokia.com", "distribution_model": "default", "packages": "pkg_1-tests pkg_2-tests pkg_3-tests" } options = Options(**kwargs) self.assertEquals(["pkg_1-tests", "pkg_2-tests", "pkg_3-tests"], options.hw_packages)
def test_image(self): options = Options(**{ "image": "www.nokia.com", "distribution_model": "default" }) self.assertEquals("www.nokia.com", options.image)