def test_only_graph_traversals_are_accepted(self):
        """
        Verifies that ValueError is risen if the parameter add is not a traversal

        @since 1.1.0
        @jira_ticket PYTHON-789
        @expected_result ValueError is arisen

        @test_category dse graph
        """
        batch = DseGraph.batch()
        self.assertRaises(ValueError, batch.add, '{"@value":{"step":[["addV","poc_int"],'
                                                 '["property","bigint1value",{"@value":12,"@type":"g:Int32"}]]},'
                                                 '"@type":"g:Bytecode"}')
        another_batch = DseGraph.batch()
        self.assertRaises(ValueError, batch.add, another_batch)
Beispiel #2
0
    def setUp(self):
        super(BatchStatementTests, self).setUp()
        self.g = self.fetch_traversal_source()

        if hasattr(self, "batch"):
            self.batch.clear()
        else:
            self.batch = DseGraph.batch(session=self.session,
                                        execution_profile=self.ep)
Beispiel #3
0
    def _send_batch_and_read_results(self,
                                     schema,
                                     graphson,
                                     add_all=False,
                                     use_schema=True):
        traversals = []
        datatypes = schema.fixtures.datatypes()
        values = {}
        g = self.fetch_traversal_source(graphson)
        ep = self.get_execution_profile(graphson)
        batch = DseGraph.batch(session=self.session,
                               execution_profile=self.get_execution_profile(
                                   graphson, traversal=True))
        for data in six.itervalues(datatypes):
            typ, value, deserializer = data
            vertex_label = VertexLabel([typ])
            property_name = next(six.iterkeys(vertex_label.non_pk_properties))
            values[property_name] = value
            if use_schema or schema is CoreGraphSchema:
                schema.create_vertex_label(self.session,
                                           vertex_label,
                                           execution_profile=ep)

            traversal = g.addV(str(vertex_label.label)).property(
                'pkid', vertex_label.id).property(property_name, value)
            if not add_all:
                batch.add(traversal)
            traversals.append(traversal)

        if add_all:
            batch.add_all(traversals)

        self.assertEqual(len(datatypes), len(batch))

        batch.execute()

        vertices = self.execute_traversal(g.V(), graphson)
        self.assertEqual(len(vertices), len(datatypes),
                         "g.V() returned {}".format(vertices))

        # Iterate over all the vertices and check that they match the original input
        for vertex in vertices:
            schema.ensure_properties(self.session,
                                     vertex,
                                     execution_profile=ep)
            key = [k for k in list(vertex.properties.keys())
                   if k != 'pkid'][0].replace("value", "")
            original = values[key]
            self._check_equality(original, vertex)