def test_base_project_integration_model_serializer_save_updates_existing_if_soft_deleted(  # type: ignore[no-untyped-def]  # noqa: E501
    project,
):
    """
    To avoid creating a model only for testing, we use the DataDogConfigurationSerializer, which subclasses
    BaseProjectIntegrationModelSerializer.
    """

    # Given
    old_url = "https://old.datadog.url"
    old_api_key = "some-old-key"

    new_url = "https://new.datadog.url"
    new_api_key = "some-new-key"

    serializer = DataDogConfigurationSerializer(
        data={"base_url": new_url, "api_key": new_api_key}
    )

    # create an existing webhookconfiguration object that has been soft deleted
    DataDogConfiguration.objects.create(
        project=project,
        base_url=old_url,
        api_key=old_api_key,
        deleted_at=timezone.now(),
    )

    serializer.is_valid(raise_exception=True)

    # When
    serializer.save(project_id=project.id)

    # Then
    updated_webhook_config = DataDogConfiguration.objects.filter(
        project=project
    ).first()
    assert updated_webhook_config is not None
    assert updated_webhook_config.base_url == new_url
    assert updated_webhook_config.api_key == new_api_key
    assert updated_webhook_config.deleted_at is None

    To avoid creating a model only for testing, we use the DataDogConfigurationSerializer, which subclasses
    BaseProjectIntegrationModelSerializer.
    
api/tests/unit/integrations/common/test_unit_integrations_common_serializers.py