-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support use of QueryResult as a context manager (#3009)
- Loading branch information
1 parent
c554a20
commit 45c5aa9
Showing
3 changed files
with
135 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,46 @@ | ||
def test_get_column_names(establish_connection): | ||
conn, db = establish_connection | ||
result = conn.execute("MATCH (a:person)-[e:knows]->(b:person) RETURN a.fName, e.date, b.ID;") | ||
column_names = result.get_column_names() | ||
assert column_names[0] == 'a.fName' | ||
assert column_names[1] == 'e.date' | ||
assert column_names[2] == 'b.ID' | ||
result.close() | ||
with conn.execute( | ||
"MATCH (a:person)-[e:knows]->(b:person) RETURN a.fName, e.date, b.ID;" | ||
) as result: | ||
column_names = result.get_column_names() | ||
assert column_names[0] == 'a.fName' | ||
assert column_names[1] == 'e.date' | ||
assert column_names[2] == 'b.ID' | ||
|
||
|
||
def test_get_column_data_types(establish_connection): | ||
conn, db = establish_connection | ||
result = conn.execute( | ||
with conn.execute( | ||
"MATCH (p:person) RETURN p.ID, p.fName, p.isStudent, p.eyeSight, p.birthdate, p.registerTime, " | ||
"p.lastJobDuration, p.workedHours, p.courseScoresPerTerm;") | ||
column_data_types = result.get_column_data_types() | ||
assert column_data_types[0] == 'INT64' | ||
assert column_data_types[1] == 'STRING' | ||
assert column_data_types[2] == 'BOOL' | ||
assert column_data_types[3] == 'DOUBLE' | ||
assert column_data_types[4] == 'DATE' | ||
assert column_data_types[5] == 'TIMESTAMP' | ||
assert column_data_types[6] == 'INTERVAL' | ||
assert column_data_types[7] == 'INT64[]' | ||
assert column_data_types[8] == 'INT64[][]' | ||
result.close() | ||
"p.lastJobDuration, p.workedHours, p.courseScoresPerTerm;" | ||
) as result: | ||
column_data_types = result.get_column_data_types() | ||
assert column_data_types[0] == 'INT64' | ||
assert column_data_types[1] == 'STRING' | ||
assert column_data_types[2] == 'BOOL' | ||
assert column_data_types[3] == 'DOUBLE' | ||
assert column_data_types[4] == 'DATE' | ||
assert column_data_types[5] == 'TIMESTAMP' | ||
assert column_data_types[6] == 'INTERVAL' | ||
assert column_data_types[7] == 'INT64[]' | ||
assert column_data_types[8] == 'INT64[][]' | ||
|
||
|
||
def test_get_schema(establish_connection): | ||
conn, db = establish_connection | ||
with conn.execute( | ||
"MATCH (p:person) RETURN p.ID, p.fName, p.isStudent, p.eyeSight, p.birthdate, p.registerTime, " | ||
"p.lastJobDuration, p.workedHours, p.courseScoresPerTerm;" | ||
) as result: | ||
assert result.get_schema() == { | ||
'p.ID': 'INT64', | ||
'p.fName': 'STRING', | ||
'p.isStudent': 'BOOL', | ||
'p.eyeSight': 'DOUBLE', | ||
'p.birthdate': 'DATE', | ||
'p.registerTime': 'TIMESTAMP', | ||
'p.lastJobDuration': 'INTERVAL', | ||
'p.workedHours': 'INT64[]', | ||
'p.courseScoresPerTerm': 'INT64[][]' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters