def test_streams4(self): gen = Generate("gen", size=10, out_streams="*") double = Double("double", in_streams=["even", "odd"]) p = Pipeline(gen | double) with self.assertRaises(Exception) as context: p.run() self.assertTrue('Node %s emits %i items' % (gen, 1) in str(context.exception))
def test_gen_reverse_stream(self): gen = Generate("gen", size=10, reverse=True, out_streams="num") p = Pipeline(NodeGraph(gen)) p.run() output = get_output() expected_out = reversed([str(x) for x in range(10)]) self.assertCountEqual(output, expected_out)
def test_printer_batch_stream(self): gen = Generate("gen", size=10, out_streams="num") printer = Printer("printer", batch_size=Node.BATCH_SIZE_ALL) p = Pipeline(gen | printer) p.run() output = get_output() expected_out = [str([x for x in range(10)])] self.assertCountEqual(output, expected_out)
def test_printer(self): gen = Generate("gen", size=10) printer = Printer("printer", batch_size=1) p = Pipeline(gen | printer) p.run() output = get_output() expected_out = [str(x) for x in range(10)] self.assertCountEqual(output, expected_out)
def test_double(self): gen = Generate("gen", size=10) double = Double("double") p = Pipeline(gen | double) p.run() output = get_output() expected_out = [str(x * 2) for x in range(10)] self.assertCountEqual(output, expected_out)
def test_streams3(self): gen = Generate("gen", size=10, out_streams="*") double = Double("double", out_streams="num") p = Pipeline(gen | double) p.run() output = get_output() expected_out = [str(x * 2) for x in range(10)] self.maxDiff = None self.assertCountEqual(output, expected_out)
def test_double_square_stream(self): gen = Generate("gen", size=10, out_streams="num") double = Double("double", out_streams="num", in_streams="num") square = Square("square", out_streams="num", in_streams="num") p = Pipeline(gen | double | square) p.run() output = get_output() expected_out = [str((x * 2)**2) for x in range(10)] self.assertCountEqual(output, expected_out)
def test_double_and_square(self): gen = Generate("gen", size=10) double = Double("double") square = Square("square") p = Pipeline(gen | [double, square]) p.run() output = get_output() expected_out = [str(x * 2) for x in range(10)] + [str(x**2) for x in range(10)] self.assertCountEqual(output, expected_out)