8
8
9
9
from graph_notebook .configuration .generate_config import AuthModeEnum , Configuration , GremlinSection
10
10
from graph_notebook .configuration .get_config import get_config
11
+ from graph_notebook .neptune .client import (NEPTUNE_DB_SERVICE_NAME , NEPTUNE_ANALYTICS_SERVICE_NAME ,
12
+ DEFAULT_HTTP_PROTOCOL , DEFAULT_WS_PROTOCOL )
11
13
12
14
13
15
class TestGenerateConfigurationMain (unittest .TestCase ):
@@ -49,25 +51,61 @@ def test_generate_configuration_main_defaults_generic(self):
49
51
self .generate_config_from_main_and_test (expected_config )
50
52
51
53
def test_generate_configuration_main_override_defaults_neptune_reg (self ):
52
- expected_config = Configuration (self .neptune_host_reg , self .port , neptune_service = 'neptune-graph' ,
53
- auth_mode = AuthModeEnum .IAM , load_from_s3_arn = 'loader_arn' , ssl = False )
54
+ expected_config = Configuration (self .neptune_host_reg ,
55
+ self .port ,
56
+ neptune_service = 'neptune-graph' ,
57
+ auth_mode = AuthModeEnum .IAM ,
58
+ load_from_s3_arn = 'loader_arn' ,
59
+ ssl = False ,
60
+ gremlin_section = GremlinSection (
61
+ connection_protocol = DEFAULT_HTTP_PROTOCOL ,
62
+ include_protocol = True
63
+ )
64
+ )
54
65
self .generate_config_from_main_and_test (expected_config , host_type = 'neptune' )
55
66
56
67
def test_generate_configuration_main_override_defaults_neptune_no_verify (self ):
57
- expected_config = Configuration (self .neptune_host_reg , self .port , neptune_service = 'neptune-graph' ,
58
- auth_mode = AuthModeEnum .IAM , load_from_s3_arn = 'loader_arn' ,
59
- ssl = True , ssl_verify = False )
68
+ expected_config = Configuration (self .neptune_host_reg ,
69
+ self .port ,
70
+ neptune_service = 'neptune-graph' ,
71
+ auth_mode = AuthModeEnum .IAM ,
72
+ load_from_s3_arn = 'loader_arn' ,
73
+ ssl = True ,
74
+ ssl_verify = False ,
75
+ gremlin_section = GremlinSection (
76
+ connection_protocol = DEFAULT_HTTP_PROTOCOL ,
77
+ include_protocol = True
78
+ )
79
+ )
60
80
self .generate_config_from_main_and_test (expected_config , host_type = 'neptune' )
61
81
62
82
def test_generate_configuration_main_override_defaults_neptune_with_serializer (self ):
63
- expected_config = Configuration (self .neptune_host_reg , self .port , neptune_service = 'neptune-graph' ,
64
- auth_mode = AuthModeEnum .IAM , load_from_s3_arn = 'loader_arn' , ssl = False ,
65
- gremlin_section = GremlinSection (message_serializer = 'graphbinary' ))
83
+ expected_config = Configuration (self .neptune_host_reg ,
84
+ self .port ,
85
+ neptune_service = 'neptune-graph' ,
86
+ auth_mode = AuthModeEnum .IAM ,
87
+ load_from_s3_arn = 'loader_arn' ,
88
+ ssl = False ,
89
+ gremlin_section = GremlinSection (
90
+ message_serializer = 'graphbinary' ,
91
+ connection_protocol = DEFAULT_HTTP_PROTOCOL ,
92
+ include_protocol = True
93
+ )
94
+ )
66
95
self .generate_config_from_main_and_test (expected_config , host_type = 'neptune' )
67
96
68
97
def test_generate_configuration_main_override_defaults_neptune_cn (self ):
69
- expected_config = Configuration (self .neptune_host_cn , self .port , neptune_service = 'neptune-graph' ,
70
- auth_mode = AuthModeEnum .IAM , load_from_s3_arn = 'loader_arn' , ssl = False )
98
+ expected_config = Configuration (self .neptune_host_cn ,
99
+ self .port ,
100
+ neptune_service = 'neptune-graph' ,
101
+ auth_mode = AuthModeEnum .IAM ,
102
+ load_from_s3_arn = 'loader_arn' ,
103
+ ssl = False ,
104
+ gremlin_section = GremlinSection (
105
+ connection_protocol = DEFAULT_HTTP_PROTOCOL ,
106
+ include_protocol = True
107
+ )
108
+ )
71
109
self .generate_config_from_main_and_test (expected_config , host_type = 'neptune' )
72
110
73
111
def test_generate_configuration_main_override_defaults_generic (self ):
@@ -85,6 +123,48 @@ def test_generate_configuration_main_empty_args_neptune(self):
85
123
config = get_config (self .test_file_path )
86
124
self .assertEqual (expected_config .to_dict (), config .to_dict ())
87
125
126
+ def test_generate_configuration_main_gremlin_protocol_no_service (self ):
127
+ result = os .system (f'{ self .python_cmd } -m graph_notebook.configuration.generate_config '
128
+ f'--host "{ self .neptune_host_reg } " '
129
+ f'--port "{ self .port } " '
130
+ f'--neptune_service "" '
131
+ f'--auth_mode "" '
132
+ f'--ssl "" '
133
+ f'--load_from_s3_arn "" '
134
+ f'--config_destination="{ self .test_file_path } " ' )
135
+ self .assertEqual (0 , result )
136
+ config = get_config (self .test_file_path )
137
+ config_dict = config .to_dict ()
138
+ self .assertEqual (DEFAULT_WS_PROTOCOL , config_dict ['gremlin' ]['connection_protocol' ])
139
+
140
+ def test_generate_configuration_main_gremlin_protocol_db (self ):
141
+ result = os .system (f'{ self .python_cmd } -m graph_notebook.configuration.generate_config '
142
+ f'--host "{ self .neptune_host_reg } " '
143
+ f'--port "{ self .port } " '
144
+ f'--neptune_service "{ NEPTUNE_DB_SERVICE_NAME } " '
145
+ f'--auth_mode "" '
146
+ f'--ssl "" '
147
+ f'--load_from_s3_arn "" '
148
+ f'--config_destination="{ self .test_file_path } " ' )
149
+ self .assertEqual (0 , result )
150
+ config = get_config (self .test_file_path )
151
+ config_dict = config .to_dict ()
152
+ self .assertEqual (DEFAULT_WS_PROTOCOL , config_dict ['gremlin' ]['connection_protocol' ])
153
+
154
+ def test_generate_configuration_main_gremlin_protocol_analytics (self ):
155
+ result = os .system (f'{ self .python_cmd } -m graph_notebook.configuration.generate_config '
156
+ f'--host "{ self .neptune_host_reg } " '
157
+ f'--port "{ self .port } " '
158
+ f'--neptune_service "{ NEPTUNE_ANALYTICS_SERVICE_NAME } " '
159
+ f'--auth_mode "" '
160
+ f'--ssl "" '
161
+ f'--load_from_s3_arn "" '
162
+ f'--config_destination="{ self .test_file_path } " ' )
163
+ self .assertEqual (0 , result )
164
+ config = get_config (self .test_file_path )
165
+ config_dict = config .to_dict ()
166
+ self .assertEqual (DEFAULT_HTTP_PROTOCOL , config_dict ['gremlin' ]['connection_protocol' ])
167
+
88
168
def test_generate_configuration_main_empty_args_custom (self ):
89
169
expected_config = Configuration (self .neptune_host_custom , self .port , neptune_hosts = self .custom_hosts_list )
90
170
result = os .system (f'{ self .python_cmd } -m graph_notebook.configuration.generate_config '
0 commit comments