22
22
from test .util import ServerTestCase
23
23
24
24
# tag::minimal-example-import[]
25
- from neo4j .v1 import GraphDatabase
25
+ from neo4j .v1 import GraphDatabase , basic_auth
26
26
# end::minimal-example-import[]
27
27
28
28
29
29
class FreshDatabaseTestCase (ServerTestCase ):
30
30
31
31
def setUp (self ):
32
32
ServerTestCase .setUp (self )
33
- session = GraphDatabase .driver ("bolt://localhost" ).session ()
33
+ session = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) ).session ()
34
34
session .run ("MATCH (n) DETACH DELETE n" )
35
35
session .close ()
36
36
@@ -39,7 +39,7 @@ class MinimalWorkingExampleTestCase(FreshDatabaseTestCase):
39
39
40
40
def test_minimal_working_example (self ):
41
41
# tag::minimal-example[]
42
- driver = GraphDatabase .driver ("bolt://localhost" )
42
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
43
43
session = driver .session ()
44
44
45
45
session .run ("CREATE (neo:Person {name:'Neo', age:23})" )
@@ -56,7 +56,7 @@ class ExamplesTestCase(FreshDatabaseTestCase):
56
56
57
57
def test_construct_driver (self ):
58
58
# tag::construct-driver[]
59
- driver = GraphDatabase .driver ("bolt://localhost" )
59
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
60
60
# end::construct-driver[]
61
61
return driver
62
62
@@ -85,23 +85,23 @@ def test_tls_signed(self):
85
85
# end::tls-signed[]
86
86
87
87
def test_statement (self ):
88
- driver = GraphDatabase .driver ("bolt://localhost" )
88
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
89
89
session = driver .session ()
90
90
# tag::statement[]
91
91
session .run ("CREATE (person:Person {name: {name}})" , {"name" : "Neo" }).close ()
92
92
# end::statement[]
93
93
session .close ()
94
94
95
95
def test_statement_without_parameters (self ):
96
- driver = GraphDatabase .driver ("bolt://localhost" )
96
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
97
97
session = driver .session ()
98
98
# tag::statement-without-parameters[]
99
99
session .run ("CREATE (person:Person {name: 'Neo'})" ).close ()
100
100
# end::statement-without-parameters[]
101
101
session .close ()
102
102
103
103
def test_result_cursor (self ):
104
- driver = GraphDatabase .driver ("bolt://localhost" )
104
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
105
105
session = driver .session ()
106
106
# tag::result-cursor[]
107
107
search_term = "hammer"
@@ -114,7 +114,7 @@ def test_result_cursor(self):
114
114
session .close ()
115
115
116
116
def test_cursor_nesting (self ):
117
- driver = GraphDatabase .driver ("bolt://localhost" )
117
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
118
118
session = driver .session ()
119
119
# tag::retain-result-query[]
120
120
result = session .run ("MATCH (person:Person) WHERE person.dept = {dept} "
@@ -127,7 +127,7 @@ def test_cursor_nesting(self):
127
127
session .close ()
128
128
129
129
def test_result_retention (self ):
130
- driver = GraphDatabase .driver ("bolt://localhost" )
130
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
131
131
session = driver .session ()
132
132
# tag::retain-result-process[]
133
133
result = session .run ("MATCH (person:Person) WHERE person.dept = {dept} "
@@ -142,7 +142,7 @@ def test_result_retention(self):
142
142
session .close ()
143
143
144
144
def test_transaction_commit (self ):
145
- driver = GraphDatabase .driver ("bolt://localhost" )
145
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
146
146
session = driver .session ()
147
147
# tag::transaction-commit[]
148
148
tx = session .begin_transaction ()
@@ -156,7 +156,7 @@ def test_transaction_commit(self):
156
156
session .close ()
157
157
158
158
def test_transaction_rollback (self ):
159
- driver = GraphDatabase .driver ("bolt://localhost" )
159
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
160
160
session = driver .session ()
161
161
# tag::transaction-rollback[]
162
162
tx = session .begin_transaction ()
@@ -170,7 +170,7 @@ def test_transaction_rollback(self):
170
170
session .close ()
171
171
172
172
def test_result_summary_query_profile (self ):
173
- driver = GraphDatabase .driver ("bolt://localhost" )
173
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
174
174
session = driver .session ()
175
175
# tag::result-summary-query-profile[]
176
176
result = session .run ("PROFILE MATCH (p:Person {name: {name}}) "
@@ -183,7 +183,7 @@ def test_result_summary_query_profile(self):
183
183
session .close ()
184
184
185
185
def test_result_summary_notifications (self ):
186
- driver = GraphDatabase .driver ("bolt://localhost" )
186
+ driver = GraphDatabase .driver ("bolt://localhost" , auth = basic_auth ( "neo4j" , "neo4j" ) )
187
187
session = driver .session ()
188
188
# tag::result-summary-notifications[]
189
189
result = session .run ("EXPLAIN MATCH (a), (b) RETURN a,b" )
0 commit comments