def test_add_metadata_existing_metadata_overwrite(self, tmp_path):
        """Test that new metadata overwrites existing metadata with same keys."""
        # Setup - create a model with existing metadata
        input_model = get_onnx_model()

        # Add some existing metadata to the model
        onnx_model = onnx.load_model(input_model.model_path)
        onnx.helper.set_model_props(onnx_model, {"author": "original_author", "version": "0.1.0"})

        # Save model with existing metadata
        temp_model_path = tmp_path / "input_with_metadata.onnx"
        onnx.save_model(onnx_model, str(temp_model_path))

        # Create new model handler with this modified model
        from olive.model import ONNXModelHandler

        input_model_with_metadata = ONNXModelHandler(model_path=str(temp_model_path))

        config = {
            "graph_name": "overwrite_test_graph",
            "custom_metadata": {
                "author": "new_author",  # This should overwrite
                "license": "MIT",  # This should be added
            },
        }
        p = create_pass_from_dict(AddOliveMetadata, config, disable_search=True)
        output_folder = str(tmp_path / "onnx")

        # Execute
        output_model = p.run(input_model_with_metadata, output_folder)

        # Assert
        onnx_model = onnx.load_model(output_model.model_path)
        metadata_dict = {entry.key: entry.value for entry in onnx_model.metadata_props}

        assert metadata_dict["author"] == "new_author"  # Overwritten
        assert metadata_dict["version"] == "0.1.0"  # Preserved
        assert metadata_dict["license"] == "MIT"  # Added
Test that new metadata overwrites existing metadata with same keys.
test/unit_test/passes/onnx/test_add_metadata.py