Exemple #1
0
    def testShouldEchoNestedLst(self):
        test_lists = [
            types.CypherList([
                types.CypherInt(1),
                types.CypherInt(2),
                types.CypherInt(3),
                types.CypherInt(4)
            ]),
            types.CypherList([
                types.CypherString("a"),
                types.CypherString("b"),
                types.CypherString("c"),
                types.CypherString("˚C")
            ]),
            types.CypherList([types.CypherBool(True),
                              types.CypherBool(False)]),
            types.CypherList([
                types.CypherFloat(1.1),
                types.CypherFloat(2.2),
                types.CypherFloat(3.3),
                types.CypherFloat(4.4)
            ]),
            types.CypherList([types.CypherNull(None),
                              types.CypherNull(None)]),
            types.CypherList([
                types.CypherNull(None),
                types.CypherBool(True),
                types.CypherString("Hello world"),
                types.CypherInt(-1234567890),
                types.CypherFloat(1.7976931348623157E+308)
            ])
        ]

        self.createDriverAndSession()
        self.verifyCanEcho(test_lists, types.CypherList)
Exemple #2
0
    def testShouldEchoBack(self):
        if get_driver_name() in ['java']:
            self.skipTest("Not implemented in backend")

        vals = [
            types.CypherBool(True),
            types.CypherBool(False),
            types.CypherNull(),
            types.CypherInt(1),
            types.CypherInt(-7),
            types.CypherInt(-129),
            types.CypherInt(129),
            types.CypherInt(2147483647),
            types.CypherInt(-2147483647),
            #types.CypherFloat(9223372036854775807),       # TODO: Investigate
            #types.CypherFloat(-9223372036854775807),
            #types.CypherFloat(1.7976931348623157E+308),
            #types.CypherFloat(2.2250738585072014e-308),
            #types.CypherFloat(4.9E-324),
            #types.CypherFloat(0.0),  # Js can not determine if it should be 0 or 0.0
            types.CypherFloat(1.1),
            types.CypherString("1"),
            types.CypherString("-17∂ßå®"),
            types.CypherString("String"),
            types.CypherString(""),
        ]

        self.createDriverAndSession()
        for val in vals:
            self.verifyCanEcho(val)
Exemple #3
0
    def testShouldEchoVeryLongString(self):
        if get_driver_name() in ['java']:
            self.skipTest("Not implemented in backend")

        self.createDriverAndSession()
        long_string = "*" * 10000
        self.verifyCanEcho(types.CypherString(long_string))
Exemple #4
0
    def testShouldEchoNode(self):
        self.createDriverAndSession()

        result = self._session.run(
            "CREATE (n:TestLabel {num: 1, txt: 'abc'}) RETURN n")
        record = result.next()
        self.assertNotIsInstance(record, types.NullRecord)

        node = record.values[0]
        self.assertIsInstance(node, types.CypherNode)
        self.assertEqual(node.labels,
                         types.CypherList([types.CypherString('TestLabel')]))
        self.assertEqual(
            node.props,
            types.CypherMap({
                "num": types.CypherInt(1),
                "txt": types.CypherString('abc')
            }))
Exemple #5
0
    def testShouldEchoNestedMap(self):
        if get_driver_name() not in ['dotnet', 'go']:
            self.skipTest("Not implemented in backend")

        test_maps = {
            "a":
            types.CypherMap({
                "a": types.CypherInt(1),
                "b": types.CypherInt(2),
                "c": types.CypherInt(3),
                "d": types.CypherInt(4)
            }),
            "b":
            types.CypherMap({
                "a": types.CypherBool(True),
                "b": types.CypherBool(False)
            }),
            "c":
            types.CypherMap({
                "a": types.CypherFloat(1.1),
                "b": types.CypherFloat(2.2),
                "c": types.CypherFloat(3.3)
            }),
            "d":
            types.CypherMap({
                "a": types.CypherString("a"),
                "b": types.CypherString("b"),
                "c": types.CypherString("c"),
                "temp": types.CypherString("˚C")
            }),
            "e":
            types.CypherMap({"a": types.CypherNull(None)}),
            "f":
            types.CypherMap({
                "a": types.CypherInt(1),
                "b": types.CypherBool(True),
                "c": types.CypherFloat(3.3),
                "d": types.CypherString("Hello World"),
                "e": types.CypherNull(None)
            }),
        }

        self.createDriverAndSession()
        self.verifyCanEcho(types.CypherMap(test_maps))
Exemple #6
0
    def testShouldEchoNestedLists(self):
        if get_driver_name() in ['java']:
            self.skipTest("Not implemented in backend")

        test_lists = [
            types.CypherList([
                types.CypherInt(1),
                types.CypherInt(2),
                types.CypherInt(3),
                types.CypherInt(4)
            ]),
            types.CypherList([
                types.CypherString("a"),
                types.CypherString("b"),
                types.CypherString("c"),
                types.CypherString("˚C")
            ]),
            types.CypherList([types.CypherBool(True),
                              types.CypherBool(False)]),
            types.CypherList([
                types.CypherFloat(1.1),
                types.CypherFloat(2.2),
                types.CypherFloat(3.3),
                types.CypherFloat(4.4)
            ]),
            types.CypherList([types.CypherNull(None),
                              types.CypherNull(None)]),
            types.CypherList([
                types.CypherNull(None),
                types.CypherBool(True),
                types.CypherString("Hello world"),
                types.CypherInt(-1234567890),
                types.CypherFloat(123.456)
            ])
        ]

        self.createDriverAndSession()
        self.verifyCanEcho(types.CypherList(test_lists))
Exemple #7
0
    def test_graph_node(self):
        result = self._session.run(
            "CREATE (n:TestLabel {num: 1, txt: 'abc'}) RETURN n")
        record = result.next()
        self.assertNotIsInstance(record, types.NullRecord)

        node = record.values[0]
        self.assertIsInstance(node, types.CypherNode)
        self.assertEqual(node.labels, ['TestLabel'])
        self.assertEqual(
            node.props,
            types.CypherMap({
                "num": types.CypherInt(1),
                "txt": types.CypherString('abc')
            }))
Exemple #8
0
    def test_primitives(self):
        result = self._session.run("RETURN NULL, 1, 'string', [1, 'a']")
        record = result.next()
        self.assertNotIsInstance(record, types.NullRecord)

        values = record.values
        self.assertIsInstance(values[0], types.CypherNull)
        self.assertIsInstance(values[1], types.CypherInt)
        self.assertIsInstance(values[2], types.CypherString)
        self.assertIsInstance(values[3], types.CypherList)
        self.assertEqual(values[1], 1)
        self.assertEqual(values[2], 'string')
        self.assertEqual(
            values[3].value,
            [types.CypherInt(1), types.CypherString('a')])
Exemple #9
0
    def testShouldEchoVeryLongList(self):
        if get_driver_name() in ['java']:
            self.skipTest("Not implemented in backend")

        vals = [
            types.CypherNull(),
            types.CypherInt(1),
            types.CypherFloat(1.1),
            types.CypherString("hello"),
            types.CypherBool(True),
        ]

        self.createDriverAndSession()

        for val in vals:
            long_list = []
            for i in range(1000):
                long_list.append(val)
            self.verifyCanEcho(types.CypherList(long_list))
Exemple #10
0
    def testShouldEchoVeryLongMap(self):
        if get_driver_name() not in ['dotnet', 'go']:
            self.skipTest("Not implemented in backend")

        test_list = [
            types.CypherNull(None),
            types.CypherInt(1),
            types.CypherFloat(1.1),
            types.CypherString("Hello World"),
            types.CypherBool(True)
        ]

        self.createDriverAndSession()

        long_map = {}
        for cypherType in test_list:
            long_map.clear()
            for i in range(1000):
                long_map[str(i)] = cypherType
            self.verifyCanEcho(types.CypherMap(long_map))