driver.test_client   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 53
dl 0
loc 84
rs 10
c 0
b 0
f 0

6 Functions

Rating   Name   Duplication   Size   Complexity  
A test_client_eval_traversal() 0 6 1
A test_client_simple_eval() 0 6 1
A test_client_bytecode() 0 9 1
A test_client_simple_eval_bindings() 0 6 1
A test_iterate_result_set() 0 11 2
A test_connection() 0 10 1
1
'''
2
Licensed to the Apache Software Foundation (ASF) under one
3
or more contributor license agreements.  See the NOTICE file
4
distributed with this work for additional information
5
regarding copyright ownership.  The ASF licenses this file
6
to you under the Apache License, Version 2.0 (the
7
"License"); you may not use this file except in compliance
8
with the License.  You may obtain a copy of the License at
9
10
http://www.apache.org/licenses/LICENSE-2.0
11
12
Unless required by applicable law or agreed to in writing,
13
software distributed under the License is distributed on an
14
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
KIND, either express or implied.  See the License for the
16
specific language governing permissions and limitations
17
under the License.
18
'''
19
'''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492'''
20
import pytest
21
22
from gremlin_python.driver.request import RequestMessage
23
from aiogremlin.structure.graph import Graph
24
25
__author__ = 'David M. Brown ([email protected])'
26
27
28
@pytest.mark.asyncio
29
async def test_connection(connection):
30
    g = Graph().traversal()
31
    t = g.V()
32
    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
33
    results_set = await connection.write(message)
34
    results = await results_set.all()
35
    assert len(results) == 6
36
    assert isinstance(results, list)
37
    await connection.close()
38
39
40
@pytest.mark.asyncio
41
async def test_client_simple_eval(client):
42
    result_set = await client.submit('1 + 1')
43
    results = await result_set.all()
44
    assert results[0] == 2
45
    await client.close()
46
47
48
@pytest.mark.asyncio
49
async def test_client_simple_eval_bindings(client):
50
    result_set = await client.submit('x + x', {'x': 2})
51
    results = await result_set.all()
52
    assert results[0] == 4
53
    await client.close()
54
55
@pytest.mark.asyncio
56
async def test_client_eval_traversal(client):
57
    result_set = await client.submit('g.V()')
58
    results = await result_set.all()
59
    assert len(results) == 6
60
    await client.close()
61
62
63
@pytest.mark.asyncio
64
async def test_client_bytecode(client):
65
    g = Graph().traversal()
66
    t = g.V()
67
    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
68
    result_set = await client.submit(message)
69
    results = await result_set.all()
70
    assert len(results) == 6
71
    await client.close()
72
73
@pytest.mark.asyncio
74
async def test_iterate_result_set(client):
75
    g = Graph().traversal()
76
    t = g.V()
77
    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
78
    result_set = await client.submit(message)
79
    results = []
80
    async for result in result_set:
81
        results.append(result)
82
    assert len(results) == 6
83
    await client.close()
84