diff --git a/tests/wallets/fixtures/json/fixtures_rest.json b/tests/wallets/fixtures/json/fixtures_rest.json index aeaafac14..890c97dbe 100644 --- a/tests/wallets/fixtures/json/fixtures_rest.json +++ b/tests/wallets/fixtures/json/fixtures_rest.json @@ -5,6 +5,7 @@ "settings": { "corelightning_rest_url": "http://127.0.0.1:8555", "corelightning_rest_macaroon": "eNcRyPtEdMaCaRoOn", + "corelightning_rest_cert": false, "user_agent": "LNbits/Tests" } }, diff --git a/tests/wallets/test_rest_wallets.py b/tests/wallets/test_rest_wallets.py index b91724bfc..930bb80d5 100644 --- a/tests/wallets/test_rest_wallets.py +++ b/tests/wallets/test_rest_wallets.py @@ -3,6 +3,7 @@ from typing import Dict, Union from urllib.parse import urlencode import pytest +from loguru import logger from pytest_httpserver import HTTPServer from werkzeug.wrappers import Response @@ -34,14 +35,27 @@ def httpserver_listen_address(): ids=build_test_id, ) async def test_rest_wallet(httpserver: HTTPServer, test_data: WalletTest): - if test_data.skip: - pytest.skip() + test_id = build_test_id(test_data) + logger.info(f"[{test_id}]: test start") + try: + if test_data.skip: + logger.info(f"[{test_id}]: test skip") + pytest.skip() - for mock in test_data.mocks: - _apply_mock(httpserver, mock) + logger.info(f"[{test_id}]: apply {len(test_data.mocks)} mocks") + for mock in test_data.mocks: + _apply_mock(httpserver, mock) - wallet = load_funding_source(test_data.funding_source) - await check_assertions(wallet, test_data) + logger.info(f"[{test_id}]: load funding source") + wallet = load_funding_source(test_data.funding_source) + + logger.info(f"[{test_id}]: check assertions") + await check_assertions(wallet, test_data) + except Exception as exc: + logger.info(f"[{test_id}]: test failed: {exc}") + raise exc + finally: + logger.info(f"[{test_id}]: test end") def _apply_mock(httpserver: HTTPServer, mock: Mock): diff --git a/tests/wallets/test_rpc_wallets.py b/tests/wallets/test_rpc_wallets.py index 6c4799515..556ebabbb 100644 --- a/tests/wallets/test_rpc_wallets.py +++ b/tests/wallets/test_rpc_wallets.py @@ -3,6 +3,7 @@ from typing import Dict, List, Optional from unittest.mock import AsyncMock, Mock import pytest +from loguru import logger from pytest_mock.plugin import MockerFixture from lnbits.core.models import BaseWallet @@ -24,19 +25,35 @@ from tests.wallets.helpers import ( ids=build_test_id, ) async def test_wallets(mocker: MockerFixture, test_data: WalletTest): - if test_data.skip: - pytest.skip() + test_id = build_test_id(test_data) + logger.info(f"[{test_id}]: test start") - for mock in test_data.mocks: - _apply_rpc_mock(mocker, mock) + try: + if test_data.skip: + logger.info(f"[{test_id}]: test skip") + pytest.skip() - wallet = load_funding_source(test_data.funding_source) + logger.info(f"[{test_id}]: apply {len(test_data.mocks)} mocks") + for mock in test_data.mocks: + _apply_rpc_mock(mocker, mock) - expected_calls = _spy_mocks(mocker, test_data, wallet) + logger.info(f"[{test_id}]: load funding source") + wallet = load_funding_source(test_data.funding_source) - await check_assertions(wallet, test_data) + logger.info(f"[{test_id}]: spy mocks") + expected_calls = _spy_mocks(mocker, test_data, wallet) - _check_calls(expected_calls) + logger.info(f"[{test_id}]: check assertions") + await check_assertions(wallet, test_data) + + logger.info(f"[{test_id}]: check calls") + _check_calls(expected_calls) + + except Exception as exc: + logger.info(f"[{test_id}]: test failed: {exc}") + raise exc + finally: + logger.info(f"[{test_id}]: test end") def _apply_rpc_mock(mocker: MockerFixture, mock: RpcMock):