|
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
|
|
|
import os |
|
18
|
|
|
|
|
19
|
|
|
import pytest |
|
20
|
|
|
|
|
21
|
|
|
from aiogremlin import driver, exception |
|
22
|
|
|
from gremlin_python.driver import serializer |
|
23
|
|
|
|
|
24
|
|
|
import config_module |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
dirname = os.path.dirname(os.path.dirname(__file__)) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
@pytest.fixture(params=[0, 1]) |
|
31
|
|
|
def conf_module(request): |
|
32
|
|
|
if request.param: |
|
33
|
|
|
return 'config_module' |
|
34
|
|
|
else: |
|
35
|
|
|
return config_module |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
def test_cluster_default_config(event_loop): |
|
39
|
|
|
cluster = driver.Cluster(event_loop) |
|
40
|
|
|
assert cluster.config['scheme'] == 'ws' |
|
41
|
|
|
assert cluster.config['hosts'] == ['localhost'] |
|
42
|
|
|
assert cluster.config['port'] == 8182 |
|
43
|
|
|
assert cluster.config['ssl_certfile'] == '' |
|
44
|
|
|
assert cluster.config['ssl_keyfile'] == '' |
|
45
|
|
|
assert cluster.config['ssl_password'] == '' |
|
46
|
|
|
assert cluster.config['username'] == '' |
|
47
|
|
|
assert cluster.config['password'] == '' |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
def test_cluster_custom_config(event_loop, cluster_class): |
|
51
|
|
|
cluster = cluster_class(event_loop, username='dave', password='mypass', |
|
52
|
|
|
hosts=['127.0.0.1']) |
|
53
|
|
|
assert cluster.config['scheme'] == 'ws' |
|
54
|
|
|
assert cluster.config['hosts'] == ['127.0.0.1'] |
|
55
|
|
|
assert cluster.config['port'] == 8182 |
|
56
|
|
|
assert cluster.config['ssl_certfile'] == '' |
|
57
|
|
|
assert cluster.config['ssl_keyfile'] == '' |
|
58
|
|
|
assert cluster.config['ssl_password'] == '' |
|
59
|
|
|
assert cluster.config['username'] == 'dave' |
|
60
|
|
|
assert cluster.config['password'] == 'mypass' |
|
61
|
|
|
assert issubclass(cluster.config['message_serializer'], |
|
62
|
|
|
serializer.GraphSONMessageSerializer) |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
View Code Duplication |
def test_cluster_config_from_json(event_loop, cluster_class): |
|
|
|
|
|
|
66
|
|
|
cluster = cluster_class(event_loop) |
|
67
|
|
|
cluster.config_from_file(dirname + '/tests/config/config.json') |
|
68
|
|
|
assert cluster.config['scheme'] == 'wss' |
|
69
|
|
|
assert cluster.config['hosts'] == ['localhost'] |
|
70
|
|
|
assert cluster.config['port'] == 8182 |
|
71
|
|
|
assert cluster.config['ssl_certfile'] == '' |
|
72
|
|
|
assert cluster.config['ssl_keyfile'] == '' |
|
73
|
|
|
assert cluster.config['ssl_password'] == '' |
|
74
|
|
|
assert cluster.config['username'] == 'dave' |
|
75
|
|
|
assert cluster.config['password'] == 'mypass' |
|
76
|
|
|
|
|
77
|
|
|
assert issubclass(cluster.config['message_serializer'], |
|
78
|
|
|
serializer.GraphSONMessageSerializer) |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
View Code Duplication |
def test_cluster_config_from_yaml(event_loop, cluster_class): |
|
|
|
|
|
|
82
|
|
|
cluster = cluster_class(event_loop, host='gremlin-server') |
|
83
|
|
|
cluster.config_from_file(dirname + '/tests/config/config.yml') |
|
84
|
|
|
assert cluster.config['scheme'] == 'wss' |
|
85
|
|
|
assert cluster.config['hosts'] == ['localhost'] |
|
86
|
|
|
assert cluster.config['port'] == 8183 |
|
87
|
|
|
assert cluster.config['ssl_certfile'] == '' |
|
88
|
|
|
assert cluster.config['ssl_keyfile'] == '' |
|
89
|
|
|
assert cluster.config['ssl_password'] == '' |
|
90
|
|
|
assert cluster.config['username'] == '' |
|
91
|
|
|
assert cluster.config['password'] == '' |
|
92
|
|
|
assert issubclass(cluster.config['message_serializer'], |
|
93
|
|
|
serializer.GraphSONMessageSerializer) |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
def test_cluster_config_from_module(event_loop, cluster_class, conf_module): |
|
97
|
|
|
cluster = cluster_class(event_loop) |
|
98
|
|
|
cluster.config_from_module(conf_module) |
|
99
|
|
|
assert cluster.config['scheme'] == 'wss' |
|
100
|
|
|
assert cluster.config['hosts'] == ['localhost'] |
|
101
|
|
|
assert cluster.config['port'] == 8183 |
|
102
|
|
|
assert cluster.config['message_serializer'] is serializer.GraphSONMessageSerializer |
|
103
|
|
|
|