Skip to content

Commit c3229d6

Browse files
committed
Making fixes
1 parent 1f57dc0 commit c3229d6

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

nodestream_plugin_neo4j/neo4j_database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ async def _execute_query(
119119
self.log_error_messages_from_statistics(statistics)
120120
statistics.update_metrics_from_summary()
121121

122-
for record in neo4j_result.records:
123-
yield record
122+
return neo4j_result.records
124123

125124
def log_error_messages_from_statistics(self, statistics: Neo4jQueryStatistics):
126125
for error in statistics.error_messages:

nodestream_plugin_neo4j/result.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def update_metrics_from_summary(self):
211211
metric_updates: list[tuple[Metric, int]] = [
212212
(PLANNING_TIME, self.timing.planning_time_ms),
213213
(PROCESSING_TIME, self.timing.processing_time_ms),
214-
(TOTAL_TIME, self.timing.total_time_ms + self.timing.processing_time_ms),
214+
(TOTAL_TIME, self.timing.planning_time_ms + self.timing.processing_time_ms),
215215
(APOC_TIME, self.timing.apoc_time_ms),
216216
(NODES_CREATED, self.write_metrics.nodes_created),
217217
(NODES_DELETED, self.write_metrics.nodes_deleted),
@@ -229,7 +229,8 @@ def update_metrics_from_summary(self):
229229
(ERROR_MESSAGES, len(self.error_messages)),
230230
]
231231

232-
metrics.increment(*metric_updates)
232+
for metric, value in metric_updates:
233+
metrics.increment(metric, value)
233234

234235

235236
class Neo4jResult:

tests/unit/test_query.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from nodestream_plugin_neo4j.query import (
44
APOC_BATCH_QUERY_RESPONSE_FIELDS,
55
COMMIT_QUERY,
6-
NON_APOCH_COMMIT_QUERY,
6+
NON_APOC_COMMIT_QUERY,
77
RETURN_CLAUSE,
88
UNWIND_QUERY,
99
YIELD_CLAUSE,
@@ -59,23 +59,13 @@ def test_apoc_batch_response_default_initialization():
5959
assert_that(response.updateStatistics, is_(ApocUpdateStatistics))
6060

6161

62-
def test_apoc_batch_response_post_init_with_none_values():
63-
response = ApocBatchResponse(batches=5, errorMessages=None, updateStatistics=None)
64-
# __post_init__ should initialize these to defaults
65-
assert_that(response.errorMessages, equal_to({}))
66-
assert_that(response.updateStatistics, not_none())
67-
assert_that(response.updateStatistics, is_(ApocUpdateStatistics))
68-
assert_that(response.batches, equal_to(5))
69-
70-
7162
def test_apoc_batch_response_post_init_with_existing_values():
7263
existing_errors = {"error1": "message1"}
7364
existing_stats = ApocUpdateStatistics(nodesCreated=10)
7465

7566
response = ApocBatchResponse(
7667
errorMessages=existing_errors, updateStatistics=existing_stats
7768
)
78-
# __post_init__ should not overwrite existing values
7969
assert_that(response.errorMessages, equal_to(existing_errors))
8070
assert_that(response.updateStatistics, equal_to(existing_stats))
8171
assert_that(response.updateStatistics.nodesCreated, equal_to(10))
@@ -228,7 +218,7 @@ def test_query_batch_as_query_with_apoc_iterate_false():
228218

229219
result = batch.as_query(apoc_iterate=False)
230220

231-
assert_that(result.query_statement, equal_to(NON_APOCH_COMMIT_QUERY))
221+
assert_that(result.query_statement, equal_to(NON_APOC_COMMIT_QUERY))
232222
assert_that(result.is_apoc, equal_to(False))
233223
assert_that(
234224
result.parameters,
@@ -308,6 +298,6 @@ def test_commit_query_structure():
308298

309299

310300
def test_non_apoc_commit_query_structure():
311-
assert_that("UNWIND" in NON_APOCH_COMMIT_QUERY, equal_to(True))
312-
assert_that("CALL apoc.cypher.doIt" in NON_APOCH_COMMIT_QUERY, equal_to(True))
313-
assert_that("RETURN" in NON_APOCH_COMMIT_QUERY, equal_to(True))
301+
assert_that("UNWIND" in NON_APOC_COMMIT_QUERY, equal_to(True))
302+
assert_that("CALL apoc.cypher.doIt" in NON_APOC_COMMIT_QUERY, equal_to(True))
303+
assert_that("RETURN" in NON_APOC_COMMIT_QUERY, equal_to(True))

tests/unit/test_result.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def test_update_metrics_from_summary(mocker):
366366
constraints_added=2,
367367
constraints_removed=1,
368368
indexes_added=3,
369+
indexes_removed=1,
369370
)
370371

371372
stats = Neo4jQueryStatistics(
@@ -394,13 +395,14 @@ def test_update_metrics_from_summary(mocker):
394395
mocker.call(CONSTRAINTS_ADDED, 2),
395396
mocker.call(CONSTRAINTS_REMOVED, 1),
396397
mocker.call(INDEXES_ADDED, 3),
398+
mocker.call(INDEXES_REMOVED, 1),
397399
mocker.call(WAS_TERMINATED, 1), # True converted to int
398400
mocker.call(RETRIES, 2),
399401
mocker.call(ERROR_MESSAGES, 2), # len(error_messages)
400402
]
401403

402404
mock_metrics.increment.assert_has_calls(expected_calls, any_order=True)
403-
assert_that(mock_metrics.increment.call_count, equal_to(17))
405+
assert_that(mock_metrics.increment.call_count, equal_to(18))
404406

405407

406408
def test_metric_constants_are_defined():

0 commit comments

Comments
 (0)