def setUpByFilename(obj, filename, machineName=None, instanceName=None, taskRetryLimitOverrides=None, method='GET'): """ Configures obj (a unittest.TestCase instance) with obj.context @param obj: a unittest.TestCase instance @param filename: a filename like 'test-Foo.yaml' @param machineName: a machine name define in filename @param instanceName: an fsm instance name @param taskRetryLimitOverrides: a dict of {'transitionName' : taskRetryLimit} use to override values in .yaml """ obj.machineName = machineName or filename.replace('test-', '').replace( '.yaml', '') if not filename.startswith('/'): filename = os.path.join(os.path.dirname(__file__), 'yaml', filename) obj.currentConfig = config.loadYaml(filename=filename) obj.machineConfig = obj.currentConfig.machines[obj.machineName] if taskRetryLimitOverrides: overrideTaskRetryLimit(obj.machineConfig, taskRetryLimitOverrides) obj.factory = FSM(currentConfig=obj.currentConfig) obj.context = obj.factory.createFSMInstance(obj.machineConfig.name, instanceName=instanceName, method=method) obj.initialState = obj.context.initialState
def getFSMFactoryByFilename(filename): """ Returns an FSM instance @param filename: a filename like 'test-Foo.yaml' @return: an FSM instance """ machineName = getMachineNameByFilename(filename) filename = os.path.join(os.path.dirname(__file__), 'yaml', filename) currentConfig = config.loadYaml(filename=filename) factory = FSM(currentConfig=currentConfig) return factory
def setUpByFilename(obj, filename, machineName=None, instanceName=None, taskRetryLimitOverrides=None, method='GET'): """ Configures obj (a unittest.TestCase instance) with obj.context @param obj: a unittest.TestCase instance @param filename: a filename like 'test-Foo.yaml' @param machineName: a machine name define in filename @param instanceName: an fsm instance name @param taskRetryLimitOverrides: a dict of {'transitionName' : taskRetryLimit} use to override values in .yaml """ obj.machineName = machineName or filename.replace('test-', '').replace('.yaml', '') filename = os.path.join(os.path.dirname(__file__), 'yaml', filename) obj.currentConfig = config.loadYaml(filename=filename) obj.machineConfig = obj.currentConfig.machines[obj.machineName] if taskRetryLimitOverrides: overrideTaskRetryLimitRetries(obj.machineConfig, taskRetryLimitOverrides) obj.factory = FSM(currentConfig=obj.currentConfig) obj.context = obj.factory.createFSMInstance(obj.machineConfig.name, instanceName=instanceName, method=method) obj.initialState = obj.context.initialState
def test_yamlFileFound(self): import os filename = os.path.join(os.path.dirname(__file__), "yaml", "test-TestYamlFileLocation.yaml") configuration = config.loadYaml(filename=filename) self.assertTrue("MyMachine" in configuration.machines)
def test_yamlFileFound(self): import os filename = os.path.join(os.path.dirname(__file__), 'yaml', 'test-TestYamlFileLocation.yaml') configuration = config.loadYaml(filename=filename) self.assertTrue('MyMachine' in configuration.machines)