Skip to content

Commit 6eabe99

Browse files
committed
Added more person repo test scenarios and updated docstring
1 parent 5a93bfd commit 6eabe99

File tree

1 file changed

+114
-58
lines changed

1 file changed

+114
-58
lines changed

tests/integration/repo/test_person_repo.py

Lines changed: 114 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -196,46 +196,38 @@ def test_get_person_record_returns_none_when_items_have_no_person_attribute_type
196196
@pytest.mark.parametrize(
197197
("has_awscurrent_key", "has_awsprevious_key", "dynamodb_record", "expected_result"),
198198
[
199-
# If key AWSCURRENT exists, record AWSCurrent exists,
200-
# and key AWSPREVIOUS not exists, record AWSPREVIOUS not exist,
201-
# and record plain does not exist
202-
# then return record AWSCurrent with key AWSCurrent
203-
(True, False, "current", "current_record"),
204-
# If key AWSCURRENT exists, record AWSCurrent not exists,
205-
# and key AWSPREVIOUS not exists, record AWSPREVIOUS not exist,
206-
# and record plain does not exist
207-
# then person not found
199+
# No keys; no records → person not found
200+
(False, False, None, "person_not_found"),
201+
# AWSCURRENT key; no records → person not found
208202
(True, False, None, "person_not_found"),
209-
# If key AWSCURRENT exists, record AWSCurrent not exists,
210-
# and key AWSPREVIOUS not exists, record AWSPREVIOUS not exist,
211-
# and record plain does exist
212-
# then return record plain
213-
(True, False, "not_hashed", "not_hashed_record"),
214-
# If key AWSCURRENT not exists, record AWSCurrent not exists,
215-
# and key AWSPREVIOUS exists, record AWSPREVIOUS exist,
216-
# and record plain does not exist
217-
# then return record AWSPrevious with key AWSPrevious
218-
(False, True, "previous", "previous_record"),
219-
# If key AWSCURRENT not exists, record AWSCurrent not exists,
220-
# and key AWSPREVIOUS exists, record AWSPREVIOUS not exist,
221-
# and record plain does not exist
222-
# then person not found
203+
# AWSPREVIOUS key; no records → person not found
223204
(False, True, None, "person_not_found"),
224-
# If key AWSCURRENT not exists, record AWSCurrent not exists,
225-
# and key AWSPREVIOUS exists, record AWSPREVIOUS not exist,
226-
# and record plain does exist
227-
# then person not found
228-
(False, True, "not_hashed", "person_not_found"),
229-
# If key AWSCURRENT not exists, record AWSCurrent not exists,
230-
# and key AWSPREVIOUS not exists, record AWSPREVIOUS not exist,
231-
# and record plain does exist
232-
# then return record plain
205+
# Both keys; no records → person not found
206+
(True, True, None, "person_not_found"),
207+
# No keys; record='previous' but no AWS prev key → person not found
208+
(False, False, "previous", "person_not_found"),
209+
# AWSCURRENT key; record='previous' but no AWS prev key → person not found
210+
(True, False, "previous", "person_not_found"),
211+
# AWSPREVIOUS key; record='previous' and AWS prev exists → previous_record
212+
(False, True, "previous", "previous_record"),
213+
# Both keys; record='previous' and AWS prev exists → previous_record
214+
(True, True, "previous", "previous_record"),
215+
# No keys; record='current' but no AWS current → person not found
216+
(False, False, "current", "person_not_found"),
217+
# AWSCURRENT key; record='current' and AWS current exists → current_record
218+
(True, False, "current", "current_record"),
219+
# AWSPREVIOUS key; record='current' but no AWS current → person not found
220+
(False, True, "current", "person_not_found"),
221+
# Both keys; record='current' and AWS current exists → current_record
222+
(True, True, "current", "current_record"),
223+
# No keys; record='not hashed' exists → return not hashed record
233224
(False, False, "not_hashed", "not_hashed_record"),
234-
# If key AWSCURRENT not exists, record AWSCurrent not exists,
235-
# and key AWSPREVIOUS not exists, record AWSPREVIOUS not exist,
236-
# and record plain does not exist
237-
# then return person not found
238-
(False, False, None, "person_not_found"),
225+
# AWSCURRENT key; record='not hashed' exists → return not hashed record
226+
(True, False, "not_hashed", "not_hashed_record"),
227+
# AWSPREVIOUS key; record='not hashed' exists but no AWS prev → person not found
228+
(False, True, "not_hashed", "person_not_found"),
229+
# Both keys; record='not hashed' exists but matches neither AWS record → person not found
230+
(True, True, "not_hashed", "person_not_found"),
239231
],
240232
)
241233
def test_secret_key_scenarios( # noqa: PLR0913
@@ -254,69 +246,133 @@ def test_secret_key_scenarios( # noqa: PLR0913
254246
Scenarios
255247
---------
256248
257-
1. AWSCURRENT key exists; AWSCURRENT record exists.
249+
1. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
258250
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
259251
Not hashed record does not exist.
260-
→ Expect: return AWSCURRENT record ("current_record").
252+
→ Expect: person not found ("person_not_found").
261253
262254
Params:
263-
(True, False, "current", "current_record")
255+
(False, False, "None", "person_not_found")
264256
265257
2. AWSCURRENT key exists; AWSCURRENT record does not exist.
266258
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
267259
Not hashed record does not exist.
268260
→ Expect: person not found ("person_not_found").
269261
270262
Params:
271-
(True, False, None, "person_not_found")
263+
(True, False, "None", "person_not_found")
272264
273-
3. AWSCURRENT key exists; AWSCURRENT record does not exist.
274-
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
275-
Not hashed record exists.
276-
→ Expect: return not hashed record ("not_hashed_record").
265+
3. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
266+
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
267+
Not hashed record does not exist.
268+
→ Expect: person not found ("person_not_found").
277269
278270
Params:
279-
(True, False, "not_hashed", "not_hashed_record")
271+
(False, True, "None", "person_not_found")
280272
281-
4. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
282-
AWSPREVIOUS key exists; AWSPREVIOUS record exists.
273+
4. AWSCURRENT key exists; AWSCURRENT record does not exist.
274+
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
275+
Not hashed record does not exist.
276+
→ Expect: person not found ("person_not_found").
277+
278+
Params:
279+
(True, True, "None", "person_not_found")
280+
281+
5. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
282+
AWSPREVIOUS key does not exist; AWSPREVIOUS record does exist.
283+
Not hashed record does not exist.
284+
→ Expect: person not found ("person_not_found").
285+
286+
Params:
287+
(False, False, "previous", "person_not_found")
288+
289+
6. AWSCURRENT key exists; AWSCURRENT record does not exist.
290+
AWSPREVIOUS key does not exist; AWSPREVIOUS record does exist.
291+
Not hashed record does not exist.
292+
→ Expect: person not found ("person_not_found").
293+
294+
Params:
295+
(True, False, "previous", "person_not_found")
296+
297+
7. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
298+
AWSPREVIOUS key exists; AWSPREVIOUS record does exist.
283299
Not hashed record does not exist.
284300
→ Expect: return AWSPREVIOUS record ("previous_record").
285301
286302
Params:
287303
(False, True, "previous", "previous_record")
288304
289-
5. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
290-
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
305+
8. AWSCURRENT key exists; AWSCURRENT record does not exist.
306+
AWSPREVIOUS key exists; AWSPREVIOUS record exists.
307+
Not hashed record does not exist.
308+
→ Expect: return AWSPREVIOUS record ("previous_record").
309+
310+
Params:
311+
(True, True, "previous", "previous_record")
312+
313+
9. AWSCURRENT key does not exist; AWSCURRENT record does exist.
314+
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
291315
Not hashed record does not exist.
292316
→ Expect: person not found ("person_not_found").
293317
294318
Params:
295-
(False, True, None, "person_not_found")
319+
(False, False, "current", "person_not_found")
320+
321+
10. AWSCURRENT key exists; AWSCURRENT record exists.
322+
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
323+
Not hashed record does not exist.
324+
→ Expect: return AWSCURRENT record ("current_record").
325+
326+
Params:
327+
(True, False, "current", "current_record")
296328
297-
6. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
329+
11. AWSCURRENT key does not exist; AWSCURRENT record does exist.
298330
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
299-
Not hashed record exists.
331+
Not hashed record does not exist.
300332
→ Expect: person not found ("person_not_found").
301333
302334
Params:
303-
(False, True, "not_hashed", "person_not_found")
335+
(False, True, "current", "person_not_found")
304336
305-
7. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
337+
12. AWSCURRENT key exists; AWSCURRENT record exists.
338+
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
339+
Not hashed record does not exist.
340+
→ Expect: return AWSCURRENT record ("current_record").
341+
342+
Params:
343+
(True, True, "current", "current_record")
344+
345+
13. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
306346
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
307347
Not hashed record exists.
308348
→ Expect: return not hashed record ("not_hashed_record").
309349
310350
Params:
311351
(False, False, "not_hashed", "not_hashed_record")
312352
313-
8. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
353+
14. AWSCURRENT key exists; AWSCURRENT record does not exist.
314354
AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
315-
Not hashed record does not exist.
355+
Not hashed record exists.
356+
→ Expect: return not hashed record ("not_hashed_record").
357+
358+
Params:
359+
(True, False, "not_hashed", "not_hashed_record")
360+
361+
15. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
362+
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
363+
Not hashed record exists (not called because AWSPREVIOUS exists).
364+
→ Expect: person not found ("person_not_found").
365+
366+
Params:
367+
(False, True, "not_hashed", "person_not_found")
368+
369+
16. AWSCURRENT key exists; AWSCURRENT record does not exist.
370+
AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
371+
Not hashed record exists (not called because AWSPREVIOUS exists).
316372
→ Expect: person not found ("person_not_found").
317373
318374
Params:
319-
(False, False, None, "person_not_found")
375+
(True, True, "not_hashed", "person_not_found")
320376
"""
321377

322378
# Given

0 commit comments

Comments
 (0)