def test_pipeline_graph_vertex_chain_dict_to_list_internal(self): pipeline_test = pipeline.Pipeline( self.graph_test_2.get_vertices_iterator(), [ pipes.GraphVertexPipe(), pipes.ElementPropertiesPipe(internal=True) ]) expected_output = [{ '_id': 1, '_label': 'test_label', 'test_field': 8 }, { '_id': 2, '_label': 'test_label', 'test_field': 10 }, { '_id': 3, '_label': 'test_label', 'test_field': 12, 'time': 'now' }] self.assertEqual(pipeline_test.to_list(), expected_output) self.assertEqual( str(pipeline_test), '[DictKeyValueIterator(3), GraphVertexPipe(), ElementPropertiesPipe(internal:True)]' )
def to_dict(self, internal=False): """ Convert Element into Dictionary """ current_pipe = pipes.ElementPropertiesPipe(internal=internal) self.pipeline.add_pipe(current_pipe) return self
def test_pipeline_graph_vertex_chain_dict_to_list(self): graph = Graph() graph.add_vertex('test_label', {'test_field': 8}) graph.add_vertex('test_label', {'test_field': 10}) graph.add_vertex('test_label', {'test_field': 12, 'time': 'now'}) pipeline_test = pipeline.Pipeline( graph.get_vertices_iterator(), [pipes.GraphVertexPipe(), pipes.ElementPropertiesPipe()]) output = [{ 'test_field': 8 }, { 'test_field': 10 }, { 'test_field': 12, 'time': 'now' }] self.assertEqual(pipeline_test.to_list(), output)