@@ -247,12 +247,83 @@ def test_secret_key_scenarios( # noqa: PLR0913
247247 persisted_person_factory : NHSNumber ,
248248 hashing_service_factory : HashingService ,
249249):
250+ """
251+ Test scenarios for resolving which DynamoDB record to return based on the
252+ presence of AWSCURRENT key, AWSPREVIOUS key, and not hashed records.
253+
254+ Scenarios
255+ ---------
256+
257+ 1. AWSCURRENT key exists; AWSCURRENT record exists.
258+ AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
259+ Not hashed record does not exist.
260+ → Expect: return AWSCURRENT record ("current_record").
261+
262+ Params:
263+ (True, False, "current", "current_record")
264+
265+ 2. AWSCURRENT key exists; AWSCURRENT record does not exist.
266+ AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
267+ Not hashed record does not exist.
268+ → Expect: person not found ("person_not_found").
269+
270+ Params:
271+ (True, False, None, "person_not_found")
272+
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").
277+
278+ Params:
279+ (True, False, "not_hashed", "not_hashed_record")
280+
281+ 4. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
282+ AWSPREVIOUS key exists; AWSPREVIOUS record exists.
283+ Not hashed record does not exist.
284+ → Expect: return AWSPREVIOUS record ("previous_record").
285+
286+ Params:
287+ (False, True, "previous", "previous_record")
288+
289+ 5. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
290+ AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
291+ Not hashed record does not exist.
292+ → Expect: person not found ("person_not_found").
293+
294+ Params:
295+ (False, True, None, "person_not_found")
296+
297+ 6. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
298+ AWSPREVIOUS key exists; AWSPREVIOUS record does not exist.
299+ Not hashed record exists.
300+ → Expect: person not found ("person_not_found").
301+
302+ Params:
303+ (False, True, "not_hashed", "person_not_found")
304+
305+ 7. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
306+ AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
307+ Not hashed record exists.
308+ → Expect: return not hashed record ("not_hashed_record").
309+
310+ Params:
311+ (False, False, "not_hashed", "not_hashed_record")
312+
313+ 8. AWSCURRENT key does not exist; AWSCURRENT record does not exist.
314+ AWSPREVIOUS key does not exist; AWSPREVIOUS record does not exist.
315+ Not hashed record does not exist.
316+ → Expect: person not found ("person_not_found").
317+
318+ Params:
319+ (False, False, None, "person_not_found")
320+ """
321+
250322 # Given
251323 current = None if not has_awscurrent_key else AWS_CURRENT_SECRET
252324 previous = None if not has_awsprevious_key else AWS_PREVIOUS_SECRET
253325 hashing_service = hashing_service_factory (current = current , previous = previous )
254326
255- # current, previous, nothashed, none (no record)
256327 persisted_person = persisted_person_factory (secret_key = dynamodb_record ) if dynamodb_record else None
257328
258329 repo = PersonRepo (person_table , hashing_service )
0 commit comments