def test_capitalize_pipe(self): current_pipe = pipes.CapitalizePipe() current_pipe.set_starts( recommend_utils.ListIterator(['this', 'is', 'the', 'test'])) list_out = self._iterate_pipe(current_pipe) self.assertEqual(list_out, ['THIS', 'IS', 'THE', 'TEST']) self.assertEqual(str(current_pipe), 'CapitalizePipe()')
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_capitalize(self): caps_pipe = pipes.CapitalizePipe() pipeline_test = pipeline.Pipeline() pipeline_test.add_pipe(caps_pipe) pipeline_test.set_starts( recommend_utils.ListIterator(['this', 'is', 'the', 'test'])) list_out = self._iterate_pipeline(pipeline_test) self.assertEqual(list_out, ['THIS', 'IS', 'THE', 'TEST'])
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(self): caps_pipe = pipes.CapitalizePipe() caps_pipe.set_starts( recommend_utils.ListIterator(['this', 'is', 'the', 'test'])) list_out = [] try: while caps_pipe.has_next(): current_object = caps_pipe.next() list_out.append(current_object) except recommend_utils.FastNoSuchElementException: # Ignore FastNoSuchElementException pass self.assertEqual(list_out, ['THIS', 'IS', 'THE', 'TEST'])
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])