def len(self): """ len number Elements """ current_pipe = pipes.LenPipe() self.pipeline.add_pipe(current_pipe) return self
def test_pipe_cap_len_chain(self): caps_pipe = pipes.CapitalizePipe() len_pipe = pipes.LenPipe() caps_pipe.set_starts( recommend_utils.ListIterator(['this', 'is', 'the', 'test'])) len_pipe.set_starts(caps_pipe) list_out = self._iterate_pipe(len_pipe) self.assertEqual(list_out, [4, 2, 3, 4])
def test_pipeline_chain_2(self): pipeline_test = pipeline.Pipeline( recommend_utils.ListIterator(['this', 'is', 'the', 'test']), [pipes.CapitalizePipe(), pipes.LenPipe()]) list_out = [] try: while pipeline_test.has_next(): current_object = pipeline_test.next() list_out.append(current_object) except recommend_utils.FastNoSuchElementException: # Ignore FastNoSuchElementException pass self.assertEqual(list_out, [4, 2, 3, 4])
def test_pipe_cap_len_chain(self): caps_pipe = pipes.CapitalizePipe() len_pipe = pipes.LenPipe() caps_pipe.set_starts( recommend_utils.ListIterator(['this', 'is', 'the', 'test'])) len_pipe.set_starts(caps_pipe) list_out = [] try: while len_pipe.has_next(): # Make this refresh has loop current_object = len_pipe.next() list_out.append(current_object) except recommend_utils.FastNoSuchElementException: # Ignore FastNoSuchElementException pass self.assertEqual(list_out, [4, 2, 3, 4])
def test_pipeline_capitalize_len_list(self): pipeline_test = pipeline.Pipeline( recommend_utils.ListIterator(['this', 'is', 'the', 'test']), [pipes.CapitalizePipe(), pipes.LenPipe()]) self.assertEqual(pipeline_test.to_list(), [4, 2, 3, 4])
def test_pipeline_capitalize_len(self): pipeline_test = pipeline.Pipeline( recommend_utils.ListIterator(['this', 'is', 'the', 'test']), [pipes.CapitalizePipe(), pipes.LenPipe()]) list_out = self._iterate_pipeline(pipeline_test) self.assertEqual(list_out, [4, 2, 3, 4])