Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
tests hardcoded to use password, so fix that
Browse files Browse the repository at this point in the history
Get the password from the environment (NEO4J_PASSWORD) or fallback to
"password" like we were using before. This allows easier testing
against other instances.
  • Loading branch information
voutilad committed Dec 23, 2020
1 parent 4850693 commit 4fa2eba
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 26 deletions.
5 changes: 4 additions & 1 deletion manual-tests/test-bookmarks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
from time import time
import neo4j
Expand All @@ -24,7 +25,9 @@ def read(tx):
return ok

bookmarks = ()
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j", default_access_mode=neo4j.WRITE_ACCESS) as s:
s.write_transaction(write)
bookmarks = (s.last_bookmark())
Expand Down
5 changes: 4 additions & 1 deletion manual-tests/test-browser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

password = os.environ.get("NEO4J_PASSWORD", "password")

BIGQUERY = """
CALL db.labels() YIELD label RETURN {name:'labels', data:COLLECT(label)[..1000]} AS result
UNION ALL
Expand All @@ -25,6 +28,6 @@ def work(tx):
return work


with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.read_transaction(do(BIGQUERY))
5 changes: 3 additions & 2 deletions manual-tests/test-call.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -10,13 +11,13 @@ def work(tx):
print(type(r))
return work

password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.read_transaction(do("CALL dbms.functions()"))
s.read_transaction(do("CALL dbms.procedures()"))
s.read_transaction(do("CALL db.schema.visualization()"))
s.read_transaction(do("CALL db.indexes()"))
s.read_transaction(do("CALL dbms.clientConfig()"))
s.read_transaction(do("CALL dbms.showCurrentUser()"))

5 changes: 3 additions & 2 deletions manual-tests/test-close.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

debug.watch("neo4j")
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
pass

4 changes: 3 additions & 1 deletion manual-tests/test-error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j
import sys
Expand All @@ -11,8 +12,9 @@ def work(tx):
print(r)
return work

password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
try:
s.read_transaction(do("RETURN 10/0"))
Expand Down
6 changes: 4 additions & 2 deletions manual-tests/test-manualtx.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python
import os
from neo4j import debug
from time import time
import neo4j

debug.watch("neo4j")

password = os.environ.get("NEO4J_PASSWORD", "password")

#time based string key
key = time().hex()

Expand All @@ -23,7 +26,7 @@ def read(tx):
print("COULD NOT MATCH!")
return ok

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j", default_access_mode=neo4j.WRITE_ACCESS) as s:
with s.begin_transaction() as tx:
write(tx)
Expand All @@ -32,4 +35,3 @@ def read(tx):
else:
tx.rollback()
tx.close()

6 changes: 4 additions & 2 deletions manual-tests/test-manualtxok.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python
import os
from neo4j import debug
from time import time
import neo4j

debug.watch("neo4j")

password = os.environ.get("NEO4J_PASSWORD", "password")

#time based string key
key = time().hex()

Expand All @@ -23,10 +26,9 @@ def read(tx):
print("COULD NOT MATCH!")
return ok

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j", default_access_mode=neo4j.WRITE_ACCESS) as s:
with s.begin_transaction() as tx:
write(tx)
read(tx)
tx.commit()

6 changes: 4 additions & 2 deletions manual-tests/test-multi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

debug.watch("neo4j")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
for i in range(1, 3):
with driver.session(database="neo4j") as s:
r = s.run('return 1')
for i in r:
print(i)

4 changes: 3 additions & 1 deletion manual-tests/test-rollback.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python
import os
from neo4j import debug
from time import time
import neo4j

debug.watch("neo4j")
password = os.environ.get("NEO4J_PASSWORD", "password")

#time based string key
key = time().hex()
Expand All @@ -23,7 +25,7 @@ def read(tx):
print("COULD NOT MATCH!")
return ok

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j", default_access_mode=neo4j.WRITE_ACCESS) as s:
with s.begin_transaction() as tx:
write(tx)
Expand Down
5 changes: 3 additions & 2 deletions manual-tests/test-run.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

debug.watch("neo4j")
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.run('return 1').consume()

5 changes: 3 additions & 2 deletions manual-tests/test-showdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -10,8 +11,8 @@ def work(tx):
print(r)
return work

password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="system") as s:
s.read_transaction(do("SHOW DATABASES"))

6 changes: 4 additions & 2 deletions manual-tests/test-smol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -13,8 +14,9 @@ def smolRead(tx):
for r in result:
print(r)

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.write_transaction(smolWrite)
s.read_transaction(smolRead)

6 changes: 4 additions & 2 deletions manual-tests/test-system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -8,7 +9,8 @@ def read(tx):
for r in result:
print(r)

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="system") as s:
s.read_transaction(read)

6 changes: 4 additions & 2 deletions manual-tests/test-write.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -8,7 +9,8 @@ def write(tx):
for r in result:
print(r)

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.write_transaction(write)

6 changes: 4 additions & 2 deletions manual-tests/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os
from neo4j import debug
import neo4j

Expand All @@ -8,7 +9,8 @@ def read(tx):
for r in result:
print(r)

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", "password")) as driver:
password = os.environ.get("NEO4J_PASSWORD", "password")

with neo4j.GraphDatabase.driver("bolt://localhost:8888", auth=("neo4j", password)) as driver:
with driver.session(database="neo4j") as s:
s.read_transaction(read)

0 comments on commit 4fa2eba

Please sign in to comment.