6
6
QueryExecutorWithStatistics ,
7
7
)
8
8
from nodestream .metrics import (
9
- Metrics ,
9
+ INGEST_HOOKS_EXECUTED ,
10
10
NODES_UPSERTED ,
11
11
RELATIONSHIPS_UPSERTED ,
12
12
TIME_TO_LIVE_OPERATIONS ,
13
- INGEST_HOOKS_EXECUTED ,
13
+ Metrics ,
14
14
)
15
15
from nodestream .model import Node , Relationship , RelationshipWithNodes
16
16
@@ -24,44 +24,42 @@ def query_executor_with_statistics(mocker):
24
24
async def test_upsert_nodes_in_bulk_with_same_operation_increments_counter_by_size_of_list (
25
25
query_executor_with_statistics , mocker
26
26
):
27
+ nodes = [
28
+ Node ("node_type" , "node1" , "id1" ),
29
+ Node ("node_type" , "node2" , "id2" ),
30
+ ]
27
31
with Metrics .capture () as metrics :
28
32
metrics .increment = mocker .Mock ()
29
33
await query_executor_with_statistics .upsert_nodes_in_bulk_with_same_operation (
30
34
"operation" ,
31
- [ Node ( "node_type" , "node1" , "id1" ), Node ( "node_type" , "node2" , "id2" )] ,
35
+ nodes ,
32
36
)
33
37
query_executor_with_statistics .inner .upsert_nodes_in_bulk_with_same_operation .assert_awaited_once_with (
34
38
"operation" ,
35
- [ Node ( "node_type" , "node1" , "id1" ), Node ( "node_type" , "node2" , "id2" )] ,
39
+ nodes ,
36
40
)
37
41
38
42
assert "node_type" in query_executor_with_statistics .node_metric_by_type
39
43
assert (
40
44
call (query_executor_with_statistics .node_metric_by_type ["node_type" ], 2 )
41
45
in metrics .increment .call_args_list
42
46
)
43
- assert (
44
- call (NODES_UPSERTED , 2 )
45
- in metrics .increment .call_args_list
46
- )
47
+ assert call (NODES_UPSERTED , 2 ) in metrics .increment .call_args_list
47
48
48
49
49
50
@pytest .mark .asyncio
50
51
async def test_upsert_relationships_in_bulk_of_same_operation_increments_counter_by_size_of_list (
51
52
query_executor_with_statistics , mocker
52
53
):
54
+ relationships = [
55
+ RelationshipWithNodes ("node1" , "node2" , Relationship ("relationship_type" )),
56
+ RelationshipWithNodes ("node3" , "node4" , Relationship ("relationship_type" )),
57
+ ]
53
58
with Metrics .capture () as metrics :
54
59
metrics .increment = mocker .Mock ()
55
60
await query_executor_with_statistics .upsert_relationships_in_bulk_of_same_operation (
56
61
"operation" ,
57
- [
58
- RelationshipWithNodes (
59
- "node1" , "node2" , Relationship ("relationship_type" )
60
- ),
61
- RelationshipWithNodes (
62
- "node3" , "node4" , Relationship ("relationship_type" )
63
- ),
64
- ],
62
+ relationships ,
65
63
)
66
64
query_executor_with_statistics .inner .upsert_relationships_in_bulk_of_same_operation .assert_awaited_once_with (
67
65
"operation" ,
@@ -87,10 +85,7 @@ async def test_upsert_relationships_in_bulk_of_same_operation_increments_counter
87
85
)
88
86
in metrics .increment .call_args_list
89
87
)
90
- assert (
91
- call (RELATIONSHIPS_UPSERTED , 2 )
92
- in metrics .increment .call_args_list
93
- )
88
+ assert call (RELATIONSHIPS_UPSERTED , 2 ) in metrics .increment .call_args_list
94
89
95
90
96
91
@pytest .mark .asyncio
@@ -103,9 +98,7 @@ async def test_perform_ttl_op_increments_counter_by_one(
103
98
query_executor_with_statistics .inner .perform_ttl_op .assert_awaited_once_with (
104
99
"config"
105
100
)
106
- metrics .increment .assert_called_once_with (
107
- TIME_TO_LIVE_OPERATIONS
108
- )
101
+ metrics .increment .assert_called_once_with (TIME_TO_LIVE_OPERATIONS )
109
102
110
103
111
104
@pytest .mark .asyncio
@@ -118,9 +111,7 @@ async def test_execute_hook_increments_counter_by_one(
118
111
query_executor_with_statistics .inner .execute_hook .assert_awaited_once_with (
119
112
"hook"
120
113
)
121
- metrics .increment .assert_called_once_with (
122
- INGEST_HOOKS_EXECUTED
123
- )
114
+ metrics .increment .assert_called_once_with (INGEST_HOOKS_EXECUTED )
124
115
125
116
126
117
@pytest .mark .asyncio
0 commit comments