def test__attach_objects_post_save_hook_invalid_permission_error(
        self, account, request, platform_account_fixture, configure_settings
    ):
        """Ensure _attach_objects_post_save_hook() on Account model raises Error as expected."""
        account_json, account_instance = request.getfixturevalue(account)

        assert account_instance.branding_icon is not None
        assert account_instance.branding_logo is not None

        with patch("djstripe.models.account.logger") as mock_logger:
            with patch("djstripe.models.core.File") as mock_file:
                with patch.object(
                    mock_file.return_value,
                    "api_retrieve",
                    side_effect=stripe.error.PermissionError,
                ):
                    # Invoke _attach_objects_post_save_hook()
                    account_instance._attach_objects_post_save_hook(
                        cls=Account,
                        data=account_json,
                        api_key=settings.STRIPE_SECRET_KEY,
                    )

        mock_logger.warning.assert_has_calls(
            [
                call(
                    "Cannot retrieve business branding icon for acct"
                    f" {account_instance.id} with the key."
                ),
                call(
                    "Cannot retrieve business branding logo for acct"
                    f" {account_instance.id} with the key."
                ),
            ]
        )
Ensure _attach_objects_post_save_hook() on Account model raises Error as expected.
tests/test_account.py