test_connection_protocol   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 1
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
wmc 0
1
# import asyncio
2
# import uuid
3
# import pytest
4
#
5
# from goblin import exception
6
# from goblin.driver import GraphSONMessageSerializer
7
#
8
#
9
# @pytest.mark.asyncio
10
# async def test_eval(remote_graph, connection, aliases):
11
#     async with connection:
12
#         connection._message_serializer = \
13
#             serializer.GraphSONMessageSerializer()
14
#         g = remote_graph.traversal()
15
#         traversal = "g.addV('person').property('name', 'leifur')"
16
#         resp = await connection.submit(
17
#             processor='',
18
#             op='eval',
19
#             gremlin=traversal,
20
#             scriptEvalTimeout=1,
21
#             aliases=aliases)
22
#
23
#         async for msg in resp:
24
#             assert msg['label'] == 'person'
25
#
26
#
27
# @pytest.mark.asyncio
28
# async def test_bytecode(remote_graph, connection, aliases):
29
#     async with connection:
30
#         connection._message_serializer = \
31
#             serializer.GraphSONMessageSerializer()
32
#         g = remote_graph.traversal()
33
#         traversal = g.addV('person').property('name', 'leifur')
34
#         resp = await connection.submit(
35
#             processor='traversal',
36
#             op='bytecode',
37
#             gremlin=traversal.bytecode,
38
#             aliases=aliases)
39
#         async for msg in resp:
40
#             vid = msg.id
41
#         traversal = g.V(vid).label()
42
#         resp = await connection.submit(
43
#             processor='traversal',
44
#             op='bytecode',
45
#             gremlin=traversal.bytecode,
46
#             aliases=aliases)
47
#         async for msg in resp:
48
#             assert msg == 'person'
49
#         traversal = g.V(vid).name
50
#         resp = await connection.submit(
51
#             processor='traversal',
52
#             op='bytecode',
53
#             gremlin=traversal.bytecode,
54
#             aliases=aliases)
55
#         async for msg in resp:
56
#             assert msg == 'leifur'
57
#
58
#
59
# @pytest.mark.asyncio
60
# async def test_side_effects(remote_graph, connection, aliases):
61
#     async with connection:
62
#         connection._message_serializer = \
63
#             serializer.GraphSONMessageSerializer()
64
#         g = remote_graph.traversal()
65
#         # Add some nodes
66
#         traversal = g.addV('person').property('name', 'leifur')
67
#         resp = await connection.submit(
68
#             processor='traversal',
69
#             op='bytecode',
70
#             gremlin=traversal.bytecode,
71
#             aliases=aliases)
72
#         async for msg in resp:
73
#             pass
74
#         traversal = g.addV('person').property('name', 'dave')
75
#         resp = await connection.submit(
76
#             processor='traversal',
77
#             op='bytecode',
78
#             gremlin=traversal.bytecode,
79
#             aliases=aliases)
80
#         async for msg in resp:
81
#             pass
82
#         traversal = g.addV('person').property('name', 'jonathan')
83
#         resp = await connection.submit(
84
#             processor='traversal',
85
#             op='bytecode',
86
#             gremlin=traversal.bytecode,
87
#             aliases=aliases)
88
#         async for msg in resp:
89
#             pass
90
#
91
#         # # Make a query
92
#         traversal = g.V().aggregate('a').aggregate('b')
93
#         resp = await connection.submit(
94
#             processor='traversal',
95
#             op='bytecode',
96
#             gremlin=traversal.bytecode,
97
#             aliases=aliases)
98
#         request_id = resp.request_id
99
#         async for msg in resp:
100
#             pass
101
#         resp = await connection.submit(
102
#             processor='traversal',
103
#             op='keys',
104
#             sideEffect=request_id,
105
#             aliases=aliases)
106
#         keys = []
107
#         async for msg in resp:
108
#             keys.append(msg)
109
#         assert keys == ['a', 'b']
110
#
111
#         resp = await connection.submit(
112
#             processor='traversal',
113
#             op='gather',
114
#             sideEffect=request_id,
115
#             sideEffectKey='a',
116
#             aliases=aliases)
117
#         side_effects = []
118
#         async for msg in resp:
119
#             side_effects.append(msg)
120
#         assert side_effects
121
#
122
#         # Close isn't implmented yet
123
#         # resp = await connection.submit(processor='traversal', op='close',
124
#         #                                sideEffect=request_id)
125
#         # async for msg in resp:
126
#         #     print(msg)
127
#
128
#
129
# @pytest.mark.asyncio
130
# async def test_session(connection, aliases):
131
#     async with connection:
132
#         connection._message_serializer = \
133
#             serializer.GraphSONMessageSerializer()
134
#         session = str(uuid.uuid4())
135
#         resp = await connection.submit(
136
#             gremlin=
137
#             "v = g.addV('person').property('name',
138
#                                            'unused_name').next(); v",
139
#             processor='session',
140
#             op='eval',
141
#             session=session,
142
#             aliases=aliases)
143
#         async for msg in resp:
144
#             assert msg['label'] == 'person'
145
#         resp = await connection.submit(
146
#             gremlin="v.values('name')",
147
#             processor='session',
148
#             op='eval',
149
#             session=session,
150
#             aliases=aliases)
151
#         async for msg in resp:
152
#             assert msg == 'unused_name'
153
#         # Close isnt' implemented yet
154
#         # resp = await connection.submit(
155
#         #     processor='session',
156
#         #     op='close',
157
#         #     session=session)
158
#         # async for msg in resp:
159
#         #     print(msg)
160