def test__attach_objects_post_save_hook_livemode_valid_connected_account(
        self, account, livemode, request, platform_account_fixture, configure_settings
    ):
        """Ensure _attach_objects_post_save_hook() on Account model works as expected."""
        account_json, account_instance = request.getfixturevalue(account)

        with patch(
            "djstripe.models.account.get_api_key_details_by_prefix",
            return_value=("some-secret-key", livemode),
        ) as mock_get_api_key_details_by_prefix:
            # 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_get_api_key_details_by_prefix.assert_called_once_with(
            settings.STRIPE_TEST_SECRET_KEY,
        )

        assert account_instance.livemode == livemode
Ensure _attach_objects_post_save_hook() on Account model works as expected.
tests/test_account.py