mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 20:12:34 +02: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:
@@ -5,6 +5,7 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"corelightning_rest_url": "http://127.0.0.1:8555",
|
"corelightning_rest_url": "http://127.0.0.1:8555",
|
||||||
"corelightning_rest_macaroon": "eNcRyPtEdMaCaRoOn",
|
"corelightning_rest_macaroon": "eNcRyPtEdMaCaRoOn",
|
||||||
|
"corelightning_rest_cert": false,
|
||||||
"user_agent": "LNbits/Tests"
|
"user_agent": "LNbits/Tests"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -3,6 +3,7 @@ from typing import Dict, Union
|
|||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from loguru import logger
|
||||||
from pytest_httpserver import HTTPServer
|
from pytest_httpserver import HTTPServer
|
||||||
from werkzeug.wrappers import Response
|
from werkzeug.wrappers import Response
|
||||||
|
|
||||||
@@ -34,14 +35,27 @@ def httpserver_listen_address():
|
|||||||
ids=build_test_id,
|
ids=build_test_id,
|
||||||
)
|
)
|
||||||
async def test_rest_wallet(httpserver: HTTPServer, test_data: WalletTest):
|
async def test_rest_wallet(httpserver: HTTPServer, test_data: WalletTest):
|
||||||
if test_data.skip:
|
test_id = build_test_id(test_data)
|
||||||
pytest.skip()
|
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:
|
logger.info(f"[{test_id}]: apply {len(test_data.mocks)} mocks")
|
||||||
_apply_mock(httpserver, mock)
|
for mock in test_data.mocks:
|
||||||
|
_apply_mock(httpserver, mock)
|
||||||
|
|
||||||
wallet = load_funding_source(test_data.funding_source)
|
logger.info(f"[{test_id}]: load funding source")
|
||||||
await check_assertions(wallet, test_data)
|
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):
|
def _apply_mock(httpserver: HTTPServer, mock: Mock):
|
||||||
|
@@ -3,6 +3,7 @@ from typing import Dict, List, Optional
|
|||||||
from unittest.mock import AsyncMock, Mock
|
from unittest.mock import AsyncMock, Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from loguru import logger
|
||||||
from pytest_mock.plugin import MockerFixture
|
from pytest_mock.plugin import MockerFixture
|
||||||
|
|
||||||
from lnbits.core.models import BaseWallet
|
from lnbits.core.models import BaseWallet
|
||||||
@@ -24,19 +25,35 @@ from tests.wallets.helpers import (
|
|||||||
ids=build_test_id,
|
ids=build_test_id,
|
||||||
)
|
)
|
||||||
async def test_wallets(mocker: MockerFixture, test_data: WalletTest):
|
async def test_wallets(mocker: MockerFixture, test_data: WalletTest):
|
||||||
if test_data.skip:
|
test_id = build_test_id(test_data)
|
||||||
pytest.skip()
|
logger.info(f"[{test_id}]: test start")
|
||||||
|
|
||||||
for mock in test_data.mocks:
|
try:
|
||||||
_apply_rpc_mock(mocker, mock)
|
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):
|
def _apply_rpc_mock(mocker: MockerFixture, mock: RpcMock):
|
||||||
|
Reference in New Issue
Block a user