test_client.test_alias()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
import asyncio
2
import uuid
3
4
import pytest
5
6
from goblin.driver import GremlinServer
7
8
9
@pytest.mark.asyncio
10
async def test_client_auto_release(cluster):
11
    client = await cluster.connect()
12
    resp = await client.submit("1 + 1")
13
    async for msg in resp:
14
        pass
15
    await asyncio.sleep(0)
16
    host = cluster._hosts.popleft()
17
    assert len(host._pool._available) == 1
18
    await host.close()
19
20
21
@pytest.mark.asyncio
22
async def test_alias(cluster):
23
    client = await cluster.connect()
24
    aliased_client = client.alias({"g": "g1"})
25
    assert aliased_client._aliases == {"g": "g1"}
26
    assert aliased_client._cluster is client._cluster
27
    assert aliased_client._loop is client._loop
28
    await cluster.close()
29
30
31
# @pytest.mark.asyncio
32
# async def test_sessioned_client(cluster):
33
#     session = str(uuid.uuid4())
34
#     client = await cluster.connect(session=session)
35
#     assert isinstance(client.cluster, GremlinServer)
36
#     resp = await client.submit("v = g.addV('person').property(
37
#         name', 'joe').next(); v")
38
#     async for msg in resp:
39
#         try:
40
#             assert msg['properties']['name'][0]['value'] == 'joe'
41
#         except KeyError:
42
#             assert msg['properties']['name'][0]['@value']['value'] == 'joe'
43
#
44
#     resp = await client.submit("g.V(v.id()).values('name')")
45
#
46
#     async for msg in resp:
47
#         assert msg == 'joe'
48
#     await cluster.close()
49