示例#1
0
 def test_data_for_execution(self):
     v1 = PlainVariable(name='key_1', value='value_1')
     v2 = PlainVariable(name='key_2', value='value_2')
     data = {'key_1': {'value': v1}, 'key_2': {'value': v2}}
     component = self.component(data)
     execution_data = component.data_for_execution({}, {})
     self.assertIsInstance(execution_data, DataObject)
     self.assertEqual(execution_data.get_inputs(), {
         'key_1': v1,
         'key_2': v2
     })
示例#2
0
 def test_data_for_execution_lack_of_inputs(self):
     PlainVariable(name='key_1', value='value_1')
     data = {'key_1': None, 'key_2': None}
     component = self.component(data)
     self.assertRaises(ComponentDataLackException,
                       execution_data=component.data_for_execution,
                       args=[None, None])
示例#3
0
def get_variable(key, info, context, pipeline_data):
    if isinstance(info['value'], Variable):
        variable = info['value']
    else:
        if info.get('type', 'plain') == 'plain':
            variable = PlainVariable(key, info['value'])
        elif info['type'] == 'splice':
            variable = SpliceVariable(key, info['value'], context)
        elif info['type'] == 'lazy':
            variable = library.VariableLibrary.get_var_class(
                info['custom_type'])(key, info['value'], context,
                                     pipeline_data)
        else:
            raise exceptions.DataTypeErrorException(
                'Unknown type: %s, which should be one of [plain, splice, lazy]'
                % info['type'])
    return variable