From bf566c5a26acf60898ff2f6d4647b01024a88349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Wed, 5 Oct 2022 11:15:11 +0200 Subject: [PATCH] fix tests a little --- tests/core/views/test_api.py | 5 +++-- tests/helpers.py | 5 +++-- tests/mocks.py | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/core/views/test_api.py b/tests/core/views/test_api.py index e0f6b5762..d1f101cad 100644 --- a/tests/core/views/test_api.py +++ b/tests/core/views/test_api.py @@ -11,10 +11,11 @@ from lnbits.core.views.api import ( api_payment, api_payments_create_invoice, ) -from lnbits.settings import wallet_class +from lnbits.settings import get_wallet_class from ...helpers import get_random_invoice_data, is_regtest +WALLET = get_wallet_class() # check if the client is working @pytest.mark.asyncio @@ -209,7 +210,7 @@ async def test_api_payment_with_key(invoice, inkey_headers_from): # check POST /api/v1/payments: invoice creation with a description hash @pytest.mark.skipif( - wallet_class.__name__ in ["CoreLightningWallet"], + WALLET.__class__.__name__ in ["CoreLightningWallet"], reason="wallet does not support description_hash", ) @pytest.mark.asyncio diff --git a/tests/helpers.py b/tests/helpers.py index fc5931bc1..9bb10571a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -4,7 +4,7 @@ import secrets import string from lnbits.core.crud import create_payment -from lnbits.settings import wallet_class +from lnbits.settings import get_wallet_class async def credit_wallet(wallet_id: str, amount: int): @@ -35,5 +35,6 @@ async def get_random_invoice_data(): return {"out": False, "amount": 10, "memo": f"test_memo_{get_random_string(10)}"} -is_fake: bool = wallet_class.__name__ == "FakeWallet" +WALLET = get_wallet_class() +is_fake: bool = WALLET.__class__.__name__ == "FakeWallet" is_regtest: bool = not is_fake diff --git a/tests/mocks.py b/tests/mocks.py index 3fc0efae2..f2fb9818e 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -1,12 +1,13 @@ from mock import AsyncMock from lnbits import bolt11 -from lnbits.settings import WALLET +from lnbits.settings import get_wallet_class from lnbits.wallets.base import PaymentResponse, PaymentStatus, StatusResponse from lnbits.wallets.fake import FakeWallet from .helpers import get_random_string, is_fake +WALLET = get_wallet_class() # generates an invoice with FakeWallet async def generate_mock_invoice(**x):