Пример #1
0
    def test_clean_multicolumn_from_other_tab(self):
        tab_output = ProcessResult(pd.DataFrame({'A-from-tab-2': [1, 2]}))
        workflow = Workflow.create_and_init()
        tab = workflow.tabs.first()
        wfm = tab.wf_modules.create(
            order=0, last_relevant_delta_id=workflow.last_delta_id)
        wfm.cache_render_result(workflow.last_delta_id, tab_output)

        schema = ParamDType.Dict({
            'tab':
            ParamDType.Tab(),
            'columns':
            ParamDType.Multicolumn(tab_parameter='tab'),
        })
        param_values = {
            'tab': tab.slug,
            'columns': 'A-from-tab-1,A-from-tab-2'
        }
        params = Params(schema, param_values, {})
        context = RenderContext(
            workflow.id,
            TableShape(3, [
                Column('A-from-tab-1', ColumnType.NUMBER),
            ]), {
                tab.slug: StepResultShape('ok', tab_output.table_shape),
            }, params)
        result = clean_value(schema, param_values, context)
        # result['tab'] is not what we're testing here
        self.assertEqual(result['columns'], 'A-from-tab-2')
Пример #2
0
 def test_clean_multicolumn_missing_is_removed(self):
     context = RenderContext(
         None,
         TableShape(3, [
             Column('A', ColumnType.NUMBER),
             Column('B', ColumnType.NUMBER),
         ]), None, None)
     schema = ParamDType.Dict({
         'columns': ParamDType.Multicolumn(),
     })
     value = {'columns': 'A,X,B'}
     result = clean_value(schema, value, context)
     self.assertEqual(result, {'columns': 'A,B'})