def test_parallel_first_and_second(self): pi = 3.141 e = 2.718 value = {'pi' : pi, 'e' : e} pipeline = cons_split_wire() >> \ (cons_dictionary_wire({'pi' : 'PI'}) >> cons_function_component(lambda a, s: {'PI' : a['PI']})).first() >> \ (cons_dictionary_wire({'e' : 'E'}) >> cons_function_component(lambda a, s: {'E' : a['E']})).second() result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline) self.assertEquals(({'PI' : pi}, {'E' : e}), result)
def test_parallel_if(self): then_comp = cons_function_component(lambda a, s: {'z' : 'THEN'}) else_comp = cons_dictionary_wire({'c' : 'z'}) pipeline = cons_if_component(lambda a, s: a['a'] == True, then_comp, else_comp) value = {'a' : True, 'b' : 'then', 'c' : 'else'} result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline) self.assertEquals({'z' : 'THEN'}, result) value = {'a' : False, 'b' : 'then', 'c' : 'else'} result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline) self.assertEquals({'z' : 'else'}, result)
def test_parallel_dictionary_wire(self): value = {'pi' : 3.141, 'e' : 2.718} pipeline = cons_dictionary_wire({'pi' : 'PI', 'e' : 'E'}) result = ParallelPypelineHelperUnitTest.test(1, pipeline, value, None, eval_pipeline) self.assertEquals({'PI' : 3.141, 'E' : 2.718}, result)