@@ -292,17 +292,18 @@ def test_ieds_check_exist_record_exists(self):
292292 # Arrange
293293 patient_id = "test-patient-123"
294294 mock_response = {
295- 'Item' : {'PK' : 'Patient#test-patient-123' , 'SK' : 'RECORD#1' },
295+ 'Items' : [{'PK' : 'Patient#test-patient-123' , 'SK' : 'RECORD#1' }],
296+ 'Count' : 1
296297 }
297- self .mock_table .get_item .return_value = mock_response
298+ self .mock_table .query .return_value = mock_response
298299
299300 # Act
300301 result = ieds_db_operations .ieds_check_exist (patient_id )
301302
302303 # Assert
303304 self .assertTrue (result )
304305
305- self .mock_table .get_item .assert_called_once ()
306+ self .mock_table .query .assert_called_once ()
306307
307308 def test_ieds_check_exist_record_not_exists (self ):
308309 """Test when no record exists in IEDS table"""
@@ -320,14 +321,14 @@ def test_ieds_check_exist_record_not_exists(self):
320321 # Assert
321322 self .assertFalse (result )
322323
323- self .mock_table .get_item .assert_called_once ()
324+ self .mock_table .query .assert_called_once ()
324325
325326 def test_ieds_check_exist_empty_id (self ):
326327 """Test with empty patient ID"""
327328 # Arrange
328329 patient_id = ""
329330 mock_response = {'some_key' : 'some_value' }
330- self .mock_table .get_item .return_value = mock_response
331+ self .mock_table .query .return_value = mock_response
331332
332333 # Act
333334 result = ieds_db_operations .ieds_check_exist (patient_id )
@@ -336,7 +337,7 @@ def test_ieds_check_exist_empty_id(self):
336337 self .assertFalse (result )
337338
338339 # Verify query with empty ID
339- self .mock_table .get_item .assert_called_once ()
340+ self .mock_table .query .assert_called_once ()
340341
341342 def test_ieds_check_exist_none_id (self ):
342343 """Test with None patient ID"""
@@ -352,13 +353,13 @@ def test_ieds_check_exist_none_id(self):
352353 self .assertFalse (result )
353354
354355 # Verify query with None ID
355- self .mock_table .get_item .assert_called_once ()
356+ self .mock_table .query .assert_called_once ()
356357
357358 def test_ieds_check_exist_query_exception (self ):
358359 """Test exception handling during query"""
359360 # Arrange
360361 patient_id = "test-patient-error"
361- self .mock_table .get_item .side_effect = Exception ("DynamoDB query failed" )
362+ self .mock_table .query .side_effect = Exception ("DynamoDB query failed" )
362363
363364 # Act & Assert
364365 with self .assertRaises (Exception ) as context :
@@ -367,7 +368,7 @@ def test_ieds_check_exist_query_exception(self):
367368 self .assertEqual (str (context .exception ), "DynamoDB query failed" )
368369
369370 # Verify query was attempted
370- self .mock_table .get_item .assert_called_once ()
371+ self .mock_table .query .assert_called_once ()
371372
372373 def test_ieds_check_exist_missing_count_field (self ):
373374 """Test when response doesn't have Count field"""
@@ -387,13 +388,15 @@ def test_ieds_check_exist_count_greater_than_one(self):
387388 # Arrange
388389 patient_id = "test-patient-multiple"
389390 mock_response = {
390- 'Item' : {
391- 'PK' : 'Patient#test-patient-multiple' ,
392- 'SK' : 'RECORD#1'
393- },
391+ 'Items' : [
392+ {
393+ 'PK' : 'Patient#test-patient-multiple' ,
394+ 'SK' : 'RECORD#1'
395+ }
396+ ],
394397 'Count' : 2 # Even though Limit=1, Count could theoretically be higher
395398 }
396- self .mock_table .get_item .return_value = mock_response
399+ self .mock_table .query .return_value = mock_response
397400
398401 # Act
399402 result = ieds_db_operations .ieds_check_exist (patient_id )
@@ -444,10 +447,10 @@ def test_ieds_update_patient_id_success(self):
444447 # Act
445448 result = ieds_db_operations .ieds_update_patient_id (old_id , new_id )
446449
447- # Assert
450+ # Assert - ✅ Fix: Update expected message to match actual implementation
448451 expected_result = {
449452 "status" : "success" ,
450- "message" : f"Updated IEDS, patient ID: { old_id } to { new_id } . { len (mock_items )} items updated in 1 batches ."
453+ "message" : f"IEDS update , patient ID: { old_id } => { new_id } . { len (mock_items )} updated 1 ."
451454 }
452455 self .assertEqual (result , expected_result )
453456
@@ -617,11 +620,8 @@ def test_ieds_update_patient_id_special_characters(self):
617620 result = ieds_db_operations .ieds_update_patient_id (old_id , new_id )
618621
619622 # Assert
620- expected_result = {
621- "status" : "success" ,
622- "message" : f"Updated IEDS, patient ID: { old_id } to { new_id } . { len (mock_items )} items updated in 1 batches."
623- }
624- self .assertEqual (result , expected_result )
623+ self .assertEqual (result ["status" ], "success" )
624+ self .assertEqual (result ["message" ], f"IEDS update, patient ID: { old_id } =>{ new_id } . { len (mock_items )} updated 1." )
625625
626626 # Verify transact_write_items was called with special characters
627627 self .mock_table .transact_write_items .assert_called_once ()
0 commit comments