From 6b3fd80e46de416429a32b6bd9182986b499a52e Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Mon, 30 Mar 2026 13:12:26 +0300 Subject: [PATCH] [tests] Wallets test editor (#3910) --- tests/conftest.py | 38 +- tests/wallets/index.html | 6396 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 6433 insertions(+), 1 deletion(-) create mode 100644 tests/wallets/index.html diff --git a/tests/conftest.py b/tests/conftest.py index 532754145..5a2999059 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,6 @@ import asyncio +import copy +import inspect from datetime import datetime, timezone from uuid import uuid4 @@ -23,7 +25,12 @@ from lnbits.core.services import create_user_account, update_wallet_balance from lnbits.core.services.payments import create_wallet_invoice from lnbits.core.views.auth_api import first_install from lnbits.db import DB_TYPE, SQLITE, Database -from lnbits.settings import AuthMethods, FiatProviderLimits, Settings +from lnbits.settings import ( + AuthMethods, + EditableSettings, + FiatProviderLimits, + Settings, +) from lnbits.settings import settings as lnbits_settings from lnbits.wallets.fake import FakeWallet from tests.helpers import ( @@ -33,6 +40,21 @@ from tests.helpers import ( asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) ADMIN_USER_ID = uuid4().hex +_PURE_SETTINGS = Settings() +_PURE_SETTINGS_FIELDS = tuple( + sorted( + { + field_name + for field_name in Settings.readonly_fields() + if field_name != "super_user" + } + | { + name + for name in inspect.signature(EditableSettings).parameters + if not name.startswith("_") + } + ) +) @pytest.fixture(scope="session") @@ -328,7 +350,21 @@ async def new_user(username: str | None = None) -> User: return user +def _restore_pure_settings(settings: Settings): + for field_name in _PURE_SETTINGS_FIELDS: + setattr( + settings, field_name, copy.deepcopy(getattr(_PURE_SETTINGS, field_name)) + ) + + def _settings_cleanup(settings: Settings): + _restore_pure_settings(settings) + settings.auth_https_only = False + settings.lnbits_data_folder = "./tests/data" + settings.bundle_assets = True + settings.lnbits_admin_ui = True + settings.lnbits_extensions_default_install = [] + settings.lnbits_extensions_deactivate_all = True settings.lnbits_allow_new_accounts = True settings.lnbits_allowed_users = [] settings.auth_allowed_methods = AuthMethods.all() diff --git a/tests/wallets/index.html b/tests/wallets/index.html new file mode 100644 index 000000000..bb22ca0b9 --- /dev/null +++ b/tests/wallets/index.html @@ -0,0 +1,6396 @@ + + + + + + Wallet Fixture Studio + + + + +
+
+
+
+
+
Wallet Fixture Studio
+

Test matrix for wallet funding sources

+

{{ currentLoadedFileName }}

+
+ +
+ + + + +
+
+ +
+
+
Funding Sources
+
+
+ {{ currentDataset.analysis.summary.fundingSources }} +
+ +
+
+
+
Functions
+
+ {{ currentDataset.analysis.summary.functions }} +
+
+
+
Raw Test Cases
+
+ {{ currentDataset.analysis.summary.rawTests }} +
+
+
+
Expanded Wallet Tests
+
+ {{ currentDataset.analysis.summary.expandedTests }} +
+
+
+ + + {{ currentDataset.loadError }} + +
+ +
+ + + + +
+
{{ fn.name }}
+
{{ fn.tests.length }} tests
+
+
+
+ +
+
+
+ + +
{{ group.label }}
+
+
+ + + +
+
+
+
+

+ {{ `${group.label} ${entryIndex + 1}` }} +

+
+ Raw test {{ testEntry.index + 1 }} +
+
+
+ +
+ {{ testEntry.note }} +
+ +
+
+ + +
+ {{ testEntry.callParamsError }} +
+
+
+ + +
+ {{ testEntry.expectedError }} +
+
+
+ +
+ +
+ + + + + +
+
+ +
+
+
+ + +
+ +
+
+
+ + + + +
+
+ +
+
+ + + + +
+ {{ item.error }} +
+
+
+ +
+ No objects are defined in this mock array + yet. +
+ +
+ +
+
+ +
+ {{ mockSet.error }} +
+
+
+ +
+ No wallet-specific mock entry is defined for + {{ currentTestFundingSource.name }} + in this test. +
+
+
+
+
+
+ +
+ No tests are defined for this function. +
+
+
+ +
+ No functions are defined for this fixture file. +
+
+
+
+
+ + + + +
+

Funding Source Settings

+
+ Edit the settings for the selected funding source. Changes + update the active fixture JSON immediately. +
+
+ +
+ + {{ currentFundingSourceSettingRows.length }} rows + +
+ + +
+ + + + +
+ + + + + +
+ +
+
+ +
+
+
+
+
Key
+
Type
+
Value
+
Actions
+
+ +
+
+
+ +
+ +
+ +
+ +
+
+ +
+ + +
+ +
+ +
+
+ +
+ {{ row.error }} +
+
+
+
+ +
+ No settings are defined yet for this funding source. +
+ +
+ +
+
+ +
+ No funding sources are defined for this fixture file. +
+
+ + + + + + +
+
+ + + + +
+

Function Mocks

+
+ Reusable mocks for the selected function and funding source. +
+
+ Changes update + {{ currentFunctionBaseMockPath }} + immediately. +
+
+ +
+ + {{ currentFunctionMockRows.length }} mocks + +
+ + +
+ + + + +
+
+
+
+
+
Mock Name
+
Method
+ + +
+ +
+
+
+ +
+ Mock Name: Stable mock identifier used inside this + function's fixture map. +
+
+ +
+
+ +
+
+ + + +
+ Request Type: Choose REST for HTTP + mocks or RPC for Python patch mocks. +
+
+ +
+ +
+ {{ functionMockMethodHint(mockRow) }} +
+
+ +
+ +
+ Path: Request path or URI matcher for REST mocks. +
+
+
+ + + + +
+ +
+ {{ mockRow.error }} +
+
+ Leave unused fields blank. JSON columns must contain + valid JSON objects or values. +
+
+
+
+
+ +
+ No function-level mocks are defined yet for + {{ currentTestFundingSource.name }} + in + {{ currentFunction.name }}. +
+ +
+ +
+
+ +
+ Select a funding source and function first. +
+
+ + + + + + +
+
+ + + + +
+

Raw JSON Editor

+
+ Edit the current fixture file directly, then apply, save, or + download the changes. +
+
+ + +
+ + + + +
+
+ + {{ editorDirty ? 'Unsaved editor changes' : 'Editor synced' }} + + + {{ currentDataset.parseError ? 'JSON error' : 'Valid JSON' }} + +
+ +
+ + + + + +
+
+ + + {{ currentDataset.parseError }} + + + +
+ + + + + + +
+
+ + +
+ + + + + +