diff --git a/monkey/monkey_island/cc/repository/mongo_machine_repository.py b/monkey/monkey_island/cc/repository/mongo_machine_repository.py index 8e1934cc7..a3297449e 100644 --- a/monkey/monkey_island/cc/repository/mongo_machine_repository.py +++ b/monkey/monkey_island/cc/repository/mongo_machine_repository.py @@ -38,12 +38,6 @@ class MongoMachineRepository(IMachineRepository): except Exception as err: raise StorageError(f'Error updating machine with ID "{machine.id}": {err}') - if result.matched_count != 0 and result.modified_count != 1: - raise StorageError( - f'Error updating machine with ID "{machine.id}": Expected to update 1 machine, ' - f"but {result.modified_count} were updated" - ) - if result.matched_count == 0 and result.upserted_id is None: raise StorageError( f'Error inserting machine with ID "{machine.id}": Expected to insert 1 machine, ' diff --git a/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_machine_repository.py b/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_machine_repository.py index bbd35283b..7e4ef93a8 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_machine_repository.py +++ b/monkey/tests/unit_tests/monkey_island/cc/repository/test_mongo_machine_repository.py @@ -146,21 +146,6 @@ def test_upsert_machine__storage_error_exception(error_raising_machine_repositor error_raising_machine_repository.upsert_machine(machine) -def test_upsert_machine__storage_error_update_failed(error_raising_mock_mongo_client): - mock_result = MagicMock() - mock_result.matched_count = 1 - mock_result.modified_count = 0 - - error_raising_mock_mongo_client.monkey_island.machines.replace_one = MagicMock( - return_value=mock_result - ) - machine_repository = MongoMachineRepository(error_raising_mock_mongo_client) - - machine = MACHINES[0] - with pytest.raises(StorageError): - machine_repository.upsert_machine(machine) - - def test_upsert_machine__storage_error_insert_failed(error_raising_mock_mongo_client): mock_result = MagicMock() mock_result.matched_count = 0