1919# limitations under the License.
2020
2121
22+ from unittest import skip
23+
24+ from neo4j .v1 import basic_auth , TRUST_ON_FIRST_USE , TRUST_SIGNED_CERTIFICATES
2225from test .util import ServerTestCase
2326
27+ # Do not change the contents of this tagged section without good reason*
2428# tag::minimal-example-import[]
25- from neo4j .v1 import GraphDatabase , basic_auth
29+ from neo4j .v1 import GraphDatabase
2630# end::minimal-example-import[]
31+ # (* "good reason" is defined as knowing what you are doing)
32+
33+
34+ auth_token = basic_auth ("neo4j" , "password" )
2735
2836
2937class FreshDatabaseTestCase (ServerTestCase ):
3038
3139 def setUp (self ):
3240 ServerTestCase .setUp (self )
33- session = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) ).session ()
41+ session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
3442 session .run ("MATCH (n) DETACH DELETE n" )
3543 session .close ()
3644
@@ -68,40 +76,40 @@ def test_configuration(self):
6876
6977 def test_tls_require_encryption (self ):
7078 # tag::tls-require-encryption[]
71- # TODO: Unfortunately, this feature is not yet implemented for Python
72- pass
79+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token , encrypted = True )
7380 # end::tls-require-encryption[]
7481
7582 def test_tls_trust_on_first_use (self ):
7683 # tag::tls-trust-on-first-use[]
77- # TODO: Unfortunately, this feature is not yet implemented for Python
78- pass
84+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token , encrypted = True , trust = TRUST_ON_FIRST_USE )
7985 # end::tls-trust-on-first-use[]
86+ assert driver
8087
88+ @skip ("testing verified certificates not yet supported " )
8189 def test_tls_signed (self ):
8290 # tag::tls-signed[]
83- # TODO: Unfortunately, this feature is not yet implemented for Python
84- pass
91+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token , encrypted = True , trust = TRUST_SIGNED_CERTIFICATES )
8592 # end::tls-signed[]
93+ assert driver
8694
8795 def test_statement (self ):
88- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
96+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
8997 session = driver .session ()
9098 # tag::statement[]
9199 session .run ("CREATE (person:Person {name: {name}})" , {"name" : "Neo" }).close ()
92100 # end::statement[]
93101 session .close ()
94102
95103 def test_statement_without_parameters (self ):
96- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
104+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
97105 session = driver .session ()
98106 # tag::statement-without-parameters[]
99107 session .run ("CREATE (person:Person {name: 'Neo'})" ).close ()
100108 # end::statement-without-parameters[]
101109 session .close ()
102110
103111 def test_result_cursor (self ):
104- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
112+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
105113 session = driver .session ()
106114 # tag::result-cursor[]
107115 search_term = "hammer"
@@ -114,7 +122,7 @@ def test_result_cursor(self):
114122 session .close ()
115123
116124 def test_cursor_nesting (self ):
117- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
125+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
118126 session = driver .session ()
119127 # tag::retain-result-query[]
120128 result = session .run ("MATCH (person:Person) WHERE person.dept = {dept} "
@@ -127,7 +135,7 @@ def test_cursor_nesting(self):
127135 session .close ()
128136
129137 def test_result_retention (self ):
130- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
138+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
131139 session = driver .session ()
132140 # tag::retain-result-process[]
133141 result = session .run ("MATCH (person:Person) WHERE person.dept = {dept} "
@@ -142,7 +150,7 @@ def test_result_retention(self):
142150 session .close ()
143151
144152 def test_transaction_commit (self ):
145- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
153+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
146154 session = driver .session ()
147155 # tag::transaction-commit[]
148156 tx = session .begin_transaction ()
@@ -156,7 +164,7 @@ def test_transaction_commit(self):
156164 session .close ()
157165
158166 def test_transaction_rollback (self ):
159- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
167+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
160168 session = driver .session ()
161169 # tag::transaction-rollback[]
162170 tx = session .begin_transaction ()
@@ -170,7 +178,7 @@ def test_transaction_rollback(self):
170178 session .close ()
171179
172180 def test_result_summary_query_profile (self ):
173- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
181+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
174182 session = driver .session ()
175183 # tag::result-summary-query-profile[]
176184 result = session .run ("PROFILE MATCH (p:Person {name: {name}}) "
@@ -183,7 +191,7 @@ def test_result_summary_query_profile(self):
183191 session .close ()
184192
185193 def test_result_summary_notifications (self ):
186- driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "password" ) )
194+ driver = GraphDatabase .driver ("bolt://localhost" , auth = auth_token )
187195 session = driver .session ()
188196 # tag::result-summary-notifications[]
189197 result = session .run ("EXPLAIN MATCH (a), (b) RETURN a,b" )
0 commit comments