def test_all_types(self): s = self.session generate_type_graph_schema(s) for key in TYPE_MAP.keys(): vertex_label = key property_name = key + "value" _, value, deserializer = TYPE_MAP[key] s.execute_graph( "g.addV('{0}').property('{1}', type_value)".format( vertex_label, property_name), {'type_value': value}) read_results = s.execute_graph( "g.V().hasLabel('{0}')".format(vertex_label)) row = next(read_results.current_rows) self.assertEqual(len(row.properties), 1) self.assertEqual(len(list(row.properties.values())[0]), 1) self.assertIsInstance( list(row.properties.values())[0][0], VertexProperty) deserialized_value = deserializer( list(row.properties.values())[0][0].value) self.assertEqual(deserialized_value, value) self.assertRaises(StopIteration, next, read_results.current_rows) prof = s.execution_profile_clone_update( EXEC_PROFILE_GRAPH_DEFAULT, row_factory=graph_result_row_factory) rs = self.session.execute_graph("g.V()", execution_profile=prof) for result in rs: self._validate_type(result)
def test_all_graph_types_without_schema(self): """ Exhaustively goes through each type that is supported by dse_graph. creates a vertex for each type using a dse-tinkerpop traversal, It then attempts to fetch it from the server and compares it to what was inserted Do not prime the graph with the correct schema first @since 1.0.0 @jira_ticket PYTHON-641 @expected_result inserted objects are equivalent to those retrieved @test_category dse graph """ # Prime graph using common utilites generate_type_graph_schema(self.session, prime_schema=False) g = self.fetch_traversal_source() # For each supported type fetch create a vetex containing that type for key in TYPE_MAP.keys(): vertex_label = key property_name = key + "value" traversal = g.addV(vertex_label).property(property_name, TYPE_MAP[key][1]) self.execute_traversal(traversal) traversal = g.V() vertices = self.execute_traversal(traversal) # Iterate over all the vertices and check that they match the original input for vertex in vertices: original = TYPE_MAP[vertex.label][1] self._check_equality(g, original, vertex)
def test_all_types_graphson2(self): """ Sends and reads back all the available types verifying they were written correctly @since 3.20 @jira_ticket PYTHON-775 @test_category dse graph """ s = self.session generate_type_graph_schema(s) for key in TYPE_MAP.keys(): vertex_label = generate_type_graph_schema.single_vertex property_name = key + "value" _, value, deserializer = TYPE_MAP[key] s.execute_graph("g.addV('{0}').property('{1}', type_value)".format( vertex_label, property_name), {'type_value': value}, execution_profile="graphson2") read_results = s.execute_graph( "g.V().hasLabel('{0}').has('{1}')".format( vertex_label, property_name), execution_profile="graphson2") first_vertex = read_results.current_rows[0] self.assertIsInstance(first_vertex, Vertex) vertex_property = first_vertex.properties[property_name][0] self.assertIsInstance(vertex_property, VertexProperty) self.assertEqual(vertex_property.label, property_name) self.assertEqual(vertex_property.value, value) self.assertEqual(vertex_property.properties, {})
def test_all_graph_types_with_schema(self): """ Exhaustively goes through each type that is supported by dse_graph. creates a vertex for each type using a dse-tinkerpop traversal, It then attempts to fetch it from the server and compares it to what was inserted Prime the graph with the correct schema first @since 1.0.0 @jira_ticket PYTHON-641 @expected_result inserted objects are equivalent to those retrieved @test_category dse graph """ generate_type_graph_schema(self.session) # if result set is not parsed correctly this will throw an exception g = self.fetch_traversal_source() for key in TYPE_MAP.keys(): vertex_label = key property_name = key + "value" traversal = g.addV(vertex_label).property(property_name, TYPE_MAP[key][1]) results = self.execute_traversal(traversal) traversal = g.V() vertices = self.execute_traversal(traversal) for vertex in vertices: original = TYPE_MAP[vertex.label][1] self._check_equality(g, original, vertex)
def test_batch_without_schema(self): """ Sends a Batch statement and verifies it has succeeded without a schema created @since 1.1.0 @jira_ticket PYTHON-789 @expected_result ValueError is arisen @test_category dse graph """ generate_type_graph_schema(self.session) self._send_batch_and_read_results()
def test_batch_without_schema_add_all(self): """ Sends a Batch statement and verifies it has succeeded without a schema created Uses :method:`dse_graph.query._BatchGraphStatement.add_all` to add the statements instead of :method:`dse_graph.query._BatchGraphStatement.add` @since 1.1.0 @jira_ticket PYTHON-789 @expected_result ValueError is arisen @test_category dse graph """ generate_type_graph_schema(self.session, prime_schema=False) self._send_batch_and_read_results(add_all=True)
def test_all_graph_types_without_schema(self): """ Exhaustively goes through each type that is supported by dse_graph. creates a vertex for each type using a dse-tinkerpop traversal, It then attempts to fetch it from the server and compares it to what was inserted Do not prime the graph with the correct schema first @since 1.0.0 @jira_ticket PYTHON-641 @expected_result inserted objects are equivalent to those retrieved @test_category dse graph """ # Prime graph using common utilites generate_type_graph_schema(self.session, prime_schema=False) self._write_and_read_data_types()
def test_all_graph_types_with_schema(self): """ Exhaustively goes through each type that is supported by dse_graph. creates a vertex for each type using a dse-tinkerpop traversal, It then attempts to fetch it from the server and compares it to what was inserted Prime the graph with the correct schema first @since 1.0.0 @jira_ticket PYTHON-641 @expected_result inserted objects are equivalent to those retrieved @test_category dse graph """ generate_type_graph_schema(self.session) # if result set is not parsed correctly this will throw an exception self._write_and_read_data_types()