def setUp(self): """setup test environment topology""" task_terminate() # ideally shouldn't be needed... self.task = task_self() # set task topology graph = TopologyGraph() graph.add_route(NodeSet(HOSTNAME), NodeSet(NODE_GATEWAY)) graph.add_route(NodeSet(NODE_GATEWAY), NodeSet(NODE_DISTANT)) graph.add_route(NodeSet(HOSTNAME), NodeSet(NODE_DIRECT)) # NODE_FOREIGN is not included self.task.topology = graph.to_tree(HOSTNAME)
def test_004_workerclass(self): """test Defaults workerclass""" self.defaults.distant_workername = 'pdsh' task_terminate() task = task_self(self.defaults) self.assertTrue(task.default("distant_worker") is WorkerPdsh) self.defaults.distant_workername = 'ssh' self.assertTrue(task.default("distant_worker") is WorkerPdsh) task_terminate() task = task_self(self.defaults) self.assertTrue(task.default("distant_worker") is WorkerSsh) task_terminate() dname = make_temp_dir() modfile = open(os.path.join(dname, 'OutOfTree.py'), 'w') modfile.write(dedent(""" class OutOfTreeWorker(object): pass WORKER_CLASS = OutOfTreeWorker""")) modfile.flush() modfile.close() sys.path.append(dname) self.defaults.distant_workername = 'OutOfTree' task = task_self(self.defaults) self.assertTrue(task.default("distant_worker").__name__ is 'OutOfTreeWorker') task_terminate() shutil.rmtree(dname, ignore_errors=True)
def test_005_misc_value_errors(self): """test Defaults misc value errors""" task_terminate() self.defaults.local_workername = 'dummy1' self.assertRaises(ImportError, task_self, self.defaults) self.defaults.local_workername = 'exec' self.defaults.distant_workername = 'dummy2' self.assertRaises(ImportError, task_self, self.defaults) self.defaults.distant_workername = 'ssh' self.defaults.engine = 'unknown' self.assertRaises(KeyError, task_self, self.defaults) self.defaults.engine = 'auto' task = task_self(self.defaults) self.assertEqual(task.default('engine'), 'auto') task_terminate()
def test_004_workerclass(self): """test Defaults workerclass""" self.defaults.distant_workername = 'pdsh' task_terminate() task = task_self(self.defaults) self.assertTrue(task.default("distant_worker") is WorkerPdsh) self.defaults.distant_workername = 'ssh' self.assertTrue(task.default("distant_worker") is WorkerPdsh) task_terminate() task = task_self(self.defaults) self.assertTrue(task.default("distant_worker") is WorkerSsh) task_terminate()
def tearDown(self): """clean up test environment""" task_terminate() self.task = None