@@ -58,6 +58,7 @@ def setup(
5858 documents_per_type : int = 10 ,
5959 ods_code : str = "Y05868" ,
6060 out : str = "tests/performance/reference-data.json" ,
61+ output_full_pointers : bool = False ,
6162):
6263 print (f"Creating Test Data in environment '{ env } '" )
6364
@@ -77,7 +78,13 @@ def setup(
7778 nhs_numbers .add (pointer .nhs_number )
7879
7980 print (f"Created { len (documents )} documents for { len (nhs_numbers )} patients" )
80- output = json .dumps ({"documents" : documents , "nhs_numbers" : list (nhs_numbers )})
81+
82+ if output_full_pointers :
83+ output = json .dumps ({"documents" : documents , "nhs_numbers" : list (nhs_numbers )})
84+ else :
85+ output = json .dumps (
86+ {"pointer_ids" : list (documents .keys ()), "nhs_numbers" : list (nhs_numbers )}
87+ )
8188
8289 output_path = pathlib .Path (out )
8390 output_path .write_text (output )
@@ -88,12 +95,15 @@ def cleanup(env: str, input: str = "tests/performance/reference-data.json"):
8895 input_path = pathlib .Path (input )
8996 data = json .loads (input_path .read_text ())
9097
91- documents = data ["documents" ]
98+ if "documents" in data :
99+ pointer_ids = data ["documents" ].keys ()
100+ else :
101+ pointer_ids = data ["pointer_ids" ]
92102
93- print (f"Cleaning up { len (documents )} document pointers in environment '{ env } '" )
103+ print (f"Cleaning up { len (pointer_ids )} document pointers in environment '{ env } '" )
94104 table = DYNAMODB .Table (f"nhsd-nrlf--{ env } --document-pointer" )
95105 with table .batch_writer () as batch :
96- for id in documents . keys () :
106+ for id in pointer_ids :
97107 ods_code , document_id = id .split ("-" , maxsplit = 1 )
98108 pk = f"D#{ ods_code } #{ document_id } "
99109 batch .delete_item (Key = {"pk" : pk , "sk" : pk })
0 commit comments