test_connection_protocol   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 1
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
# # Copyright 2016 David M. Brown
2
# #
3
# # This file is part of Goblin.
4
# #
5
# # Goblin is free software: you can redistribute it and/or modify
6
# # it under the terms of the GNU Affero General Public License as published by
7
# # the Free Software Foundation, either version 3 of the License, or
8
# # (at your option) any later version.
9
# #
10
# # Goblin is distributed in the hope that it will be useful,
11
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# # GNU Affero General Public License for more details.
14
# #
15
# # You should have received a copy of the GNU Affero General Public License
16
# # along with Goblin.  If not, see <http://www.gnu.org/licenses/>.
17
#
18
# import asyncio
19
# import uuid
20
# import pytest
21
#
22
# from aiogremlin import exception
23
# from gremlin_python.driver import request, serializer
24
#
25
#
26
# @pytest.mark.asyncio
27
# async def test_eval(remote_graph, connection, aliases):
28
#     async with connection:
29
#         connection._message_serializer = serializer.GraphSONMessageSerializer()
30
#         g = remote_graph.traversal()
31
#         traversal = "g.addV('person').property('name', 'leifur')"
32
#         message = request.RequestMessage(
33
#             processor='', op='eval',
34
#             args={'gremlin': message,
35
#                   'aliases': aliases})
36
#         resp = await connection.submit(
37
#             processor='', op='eval', gremlin=traversal, scriptEvalTimeout=1, aliases=aliases)
38
#
39
#         async for msg in resp:
40
#             assert msg['label'] == 'person'
41
#
42
#
43
# @pytest.mark.asyncio
44
# async def test_bytecode(remote_graph, connection, aliases):
45
#     async with connection:
46
#         connection._message_serializer = serializer.GraphSONMessageSerializer()
47
#         g = remote_graph.traversal()
48
#         traversal = g.addV('person').property('name', 'leifur')
49
#         message = request.RequestMessage(
50
#             processor='traversal', op='bytecode',
51
#             args={'gremlin': traversal.bytecode,
52
#                   'aliases': aliases})
53
#         resp = await connection.submit(message)
54
#         async for msg in resp:
55
#             vid = msg.id
56
#         traversal = g.V(vid).label()
57
#         message = request.RequestMessage(
58
#             processor='traversal', op='bytecode',
59
#             args={'gremlin': traversal.bytecode,
60
#                   'aliases': aliases})
61
#         resp = await connection.submit(message)
62
#         async for msg in resp:
63
#             assert msg == 'person'
64
#         traversal = g.V(vid).name
65
#         message = request.RequestMessage(
66
#             processor='traversal', op='bytecode',
67
#             args={'gremlin': traversal.bytecode,
68
#                   'aliases': aliases})
69
#         resp = await connection.submit(message)
70
#         async for msg in resp:
71
#             assert msg == 'leifur'
72
#
73
#
74
# @pytest.mark.asyncio
75
# async def test_side_effects(remote_graph, connection, aliases):
76
#     async with connection:
77
#         connection._message_serializer = serializer.GraphSONMessageSerializer()
78
#         g = remote_graph.traversal()
79
#         # Add some nodes
80
#         traversal = g.addV('person').property('name', 'leifur')
81
#         resp = await connection.submit(
82
#             processor='traversal', op='bytecode', gremlin=traversal.bytecode, aliases=aliases)
83
#         async for msg in resp:
84
#             pass
85
#         traversal = g.addV('person').property('name', 'dave')
86
#         resp = await connection.submit(
87
#             processor='traversal', op='bytecode', gremlin=traversal.bytecode, aliases=aliases)
88
#         async for msg in resp:
89
#             pass
90
#         traversal = g.addV('person').property('name', 'jonathan')
91
#         resp = await connection.submit(
92
#             processor='traversal', op='bytecode', gremlin=traversal.bytecode, aliases=aliases)
93
#         async for msg in resp:
94
#             pass
95
#
96
#         # # Make a query
97
#         traversal = g.V().aggregate('a').aggregate('b')
98
#         resp = await connection.submit(
99
#             processor='traversal', op='bytecode', gremlin=traversal.bytecode, aliases=aliases)
100
#         request_id = resp.request_id
101
#         async for msg in resp:
102
#             pass
103
#         resp = await connection.submit(processor='traversal', op='keys',
104
#                                        sideEffect=request_id, aliases=aliases)
105
#         keys = []
106
#         async for msg in resp:
107
#             keys.append(msg)
108
#         assert keys == ['a', 'b']
109
#
110
#         resp = await connection.submit(processor='traversal', op='gather',
111
#                                        sideEffect=request_id,
112
#                                        sideEffectKey='a', aliases=aliases)
113
#         side_effects = []
114
#         async for msg in resp:
115
#             side_effects.append(msg)
116
#         assert side_effects
117
#
118
#         # Close isn't implmented yet
119
#         # resp = await connection.submit(processor='traversal', op='close',
120
#         #                                sideEffect=request_id)
121
#         # async for msg in resp:
122
#         #     print(msg)
123
#
124
#
125
# @pytest.mark.asyncio
126
# async def test_session(connection, aliases):
127
#     async with connection:
128
#         connection._message_serializer = serializer.GraphSONMessageSerializer()
129
#         session = str(uuid.uuid4())
130
#         resp = await connection.submit(
131
#             gremlin="v = g.addV('person').property('name', 'unused_name').next(); v",
132
#             processor='session',
133
#             op='eval',
134
#             session=session,
135
#             aliases=aliases)
136
#         async for msg in resp:
137
#             assert msg['label'] == 'person'
138
#         resp = await connection.submit(
139
#             gremlin="v.values('name')",
140
#             processor='session',
141
#             op='eval',
142
#             session=session,
143
#             aliases=aliases)
144
#         async for msg in resp:
145
#             assert msg == 'unused_name'
146
#         # Close isnt' implemented yet
147
#         # resp = await connection.submit(
148
#         #     processor='session',
149
#         #     op='close',
150
#         #     session=session)
151
#         # async for msg in resp:
152
#         #     print(msg)
153