Skip to content

Commit 4fe2fad

Browse files
committed
PYTHON-2856 Properly assert 0 events in snapshot reads tests (#697)
expectEvents must be non-empty if present. (cherry picked from commit c663fb6)
1 parent d58b385 commit 4fe2fad

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

test/sessions/unified/snapshot-sessions-not-supported-client-error.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@
7070
}
7171
}
7272
],
73-
"expectEvents": []
73+
"expectEvents": [
74+
{
75+
"client": "client0",
76+
"events": []
77+
}
78+
]
7479
},
7580
{
7681
"description": "Client error on aggregate with snapshot",
@@ -88,7 +93,12 @@
8893
}
8994
}
9095
],
91-
"expectEvents": []
96+
"expectEvents": [
97+
{
98+
"client": "client0",
99+
"events": []
100+
}
101+
]
92102
},
93103
{
94104
"description": "Client error on distinct with snapshot",
@@ -107,7 +117,12 @@
107117
}
108118
}
109119
],
110-
"expectEvents": []
120+
"expectEvents": [
121+
{
122+
"client": "client0",
123+
"events": []
124+
}
125+
]
111126
}
112127
]
113128
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"description": "test-expectEvents-minItems",
3+
"schemaVersion": "1.0",
4+
"tests": [
5+
{
6+
"description": "foo",
7+
"operations": [],
8+
"expectEvents": []
9+
}
10+
]
11+
}

test/unified_format.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,10 @@ def run_scenario(self, spec):
11421142
self.run_operations(spec['operations'])
11431143

11441144
# process expectEvents
1145-
self.check_events(spec.get('expectEvents', []))
1145+
if 'expectEvents' in spec:
1146+
expect_events = spec['expectEvents']
1147+
self.assertTrue(expect_events, 'expectEvents must be non-empty')
1148+
self.check_events(expect_events)
11461149

11471150
# process outcome
11481151
self.verify_outcome(spec.get('outcome', []))

0 commit comments

Comments
 (0)