mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-15 12:20:21 +01:00
feat: extra log for tests phases (#2604)
* fix: set `corelightning_rest_cert` * feat: extra log for tests phases --------- Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
parent
0387db3b55
commit
b41705167f
3 changed files with 46 additions and 14 deletions
|
@ -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"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue