def test__find_owner_account(
    mock__get_or_retrieve,
    mock_get_or_retrieve_for_api_key,
    api_key,
    stripe_account,
    has_stripe_account_attr,
    monkeypatch,
):
    """
    Test that the correct classmethod is invoked with the correct arguments
    to get the owner account
    """

    # fake_data_class used to invoke _find_owner_account classmethod
    class fake_data_class:
        @property
        def stripe_account(self):
            return stripe_account

        def get(*args, **kwargs):
            return "customer"

    fake_data = fake_data_class()

    if api_key is None:
        # invoke _find_owner_account without the api_key parameter
        StripeModel._find_owner_account(fake_data)
    else:
        # invoke _find_owner_account with the api_key parameter
        StripeModel._find_owner_account(fake_data, api_key=api_key)

    if has_stripe_account_attr and stripe_account:
        if api_key:
            mock__get_or_retrieve.assert_called_once_with(
                id=stripe_account, api_key=api_key
            )
        else:
            mock__get_or_retrieve.assert_called_once_with(
                id=stripe_account, api_key=djstripe_settings.STRIPE_SECRET_KEY
            )

    else:
        if api_key:
            mock_get_or_retrieve_for_api_key.assert_called_once_with(api_key)
        else:
            mock_get_or_retrieve_for_api_key.assert_called_once_with(
                djstripe_settings.STRIPE_SECRET_KEY
            )

    Test that the correct classmethod is invoked with the correct arguments
    to get the owner account
    
tests/test_stripe_model.py