Wire admin add-account endpoint into the UI #46
1 changed files with 29 additions and 1 deletions
test(harness): split-layout ledger + disable rate limiter
The test harness was never updated to the post-server-deploy#4 split ledger layout, so libra's per-user account opens (routed to accounts/users.beancount by fava_client._infer_target_file) 500'd as a 'non-source file' and fell back to DB-only — breaking the balance test and contributing to settlement errors. Make the harness ledger a faithful split (root includes accounts/chart.beancount + accounts/users.beancount; title stays in root so the slug still matches). Also raise lnbits_rate_limit_no for the session: the full suite fires >200 req/min and the default limiter 429'd fixture setup intermittently (10-11 errors). The limiter is built once at app creation, so setting it in the session settings fixture (before the app fixture) disables it suite-wide. Net: full suite goes from 1 failed / ~10 errors to fully green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
commit
87a45ee4d5
|
|
@ -108,6 +108,9 @@ def _settings_cleanup(settings: Settings) -> None:
|
|||
settings.lnbits_user_activation_by_invitation_code = False
|
||||
settings.lnbits_register_reusable_activation_code = ""
|
||||
settings.lnbits_register_one_time_activation_codes = []
|
||||
# Keep the rate limiter disabled across per-test settings resets (the
|
||||
# limiter itself is fixed at app-creation time, but keep the value coherent).
|
||||
settings.lnbits_rate_limit_no = 1_000_000
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
|
@ -133,6 +136,12 @@ def settings() -> Iterator[Settings]:
|
|||
lnbits_settings.lnbits_admin_ui = True
|
||||
lnbits_settings.lnbits_extensions_default_install = []
|
||||
lnbits_settings.lnbits_extensions_deactivate_all = False
|
||||
# The full suite fires >200 requests/minute; the default rate limit (200/min)
|
||||
# otherwise 429s fixture setup intermittently. The limiter is built once at
|
||||
# app creation from this value (lnbits/app.py register_new_ratelimiter), and
|
||||
# this fixture runs before the `app` fixture, so raising it here disables it
|
||||
# for the session.
|
||||
lnbits_settings.lnbits_rate_limit_no = 1_000_000
|
||||
yield lnbits_settings
|
||||
|
||||
|
||||
|
|
@ -170,13 +179,32 @@ option "render_commas" "TRUE"
|
|||
2020-01-01 open Equity:Opening-Balances EUR,SATS
|
||||
2020-01-01 open Income:Generic EUR,SATS
|
||||
2020-01-01 open Expenses:Generic EUR,SATS
|
||||
|
||||
include "accounts/chart.beancount"
|
||||
include "accounts/users.beancount"
|
||||
"""
|
||||
|
||||
# Split-layout include targets, mirroring the production fava layout
|
||||
# (aiolabs/server-deploy#4). libra's fava_client routes Open directives by
|
||||
# account name (fava_client._infer_target_file): per-user accounts
|
||||
# (:User-xxxxxxxx) to accounts/users.beancount, everything else to
|
||||
# accounts/chart.beancount. Both must exist as Fava *source* files (i.e. be
|
||||
# included) or /api/source writes 500 with "non-source file". The title stays
|
||||
# in the root ledger above so Fava's slug still matches LEDGER_SLUG (scalar
|
||||
# options don't propagate from includes — see aiolabs/server-deploy#9).
|
||||
CHART_SEED = "; Admin-mutable chart of accounts (libra appends Open directives).\n"
|
||||
USERS_SEED = "; Per-user account opens (libra appends at signup).\n"
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def fava_ledger_path(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
||||
"""Session-scoped .beancount file Fava reads from."""
|
||||
"""Session-scoped split ledger Fava reads from: a root file that includes
|
||||
accounts/chart.beancount (admin add-account target) and
|
||||
accounts/users.beancount (per-user opens target)."""
|
||||
ledger_dir = tmp_path_factory.mktemp("libra-ledger")
|
||||
(ledger_dir / "accounts").mkdir()
|
||||
(ledger_dir / "accounts" / "chart.beancount").write_text(CHART_SEED)
|
||||
(ledger_dir / "accounts" / "users.beancount").write_text(USERS_SEED)
|
||||
ledger = ledger_dir / f"{LEDGER_SLUG}.beancount"
|
||||
ledger.write_text(MINIMAL_LEDGER)
|
||||
return ledger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue