@@ -625,3 +625,54 @@ def test_ieds_update_patient_id_special_characters(self):
625625
626626 # Verify transact_write_items was called with special characters
627627 self .mock_table .transact_write_items .assert_called_once ()
628+
629+
630+ class TestGetItemsToUpdate (TestIedsDbOperations ):
631+
632+ def setUp (self ):
633+ super ().setUp ()
634+ # Mock get_ieds_table()
635+ self .mock_get_ieds_table = patch ('ieds_db_operations.get_ieds_table' )
636+ self .mock_get_ieds_table_patcher = self .mock_get_ieds_table .start ()
637+ self .mock_table = MagicMock ()
638+ self .mock_get_ieds_table_patcher .return_value = self .mock_table
639+
640+ def tearDown (self ):
641+ patch .stopall ()
642+
643+ def test_get_items_to_update_success (self ):
644+ """Test successful retrieval of items to update"""
645+ # Arrange
646+ patient_id = "test-patient-123"
647+ expected_items = [
648+ {'PK' : f'Patient#{ patient_id } ' , 'PatientPK' : f'Patient#{ patient_id } ' },
649+ {'PK' : f'Patient#{ patient_id } #record1' , 'PatientPK' : f'Patient#{ patient_id } ' }
650+ ]
651+ self .mock_table .query .return_value = {
652+ 'Items' : expected_items ,
653+ 'Count' : len (expected_items )
654+ }
655+
656+ # Act
657+ result = ieds_db_operations .get_items_to_update (f"Patient#{ patient_id } " )
658+
659+ # Assert
660+ self .assertEqual (result , expected_items )
661+
662+ # Verify query was called with correct parameters
663+ self .mock_table .query .assert_called_once ()
664+
665+ def test_get_items_to_update_no_records (self ):
666+ """Test when no records are found for the patient ID"""
667+ # Arrange
668+ patient_id = "test-patient-no-records"
669+ self .mock_table .query .return_value = {
670+ 'Items' : [],
671+ 'Count' : 0
672+ }
673+
674+ # Act
675+ result = ieds_db_operations .get_items_to_update (f"Patient#{ patient_id } " )
676+
677+ # Assert
678+ self .assertEqual (result , [])
0 commit comments