fix: address account valuation review findings

This commit is contained in:
2026-10-06 14:43:29 +00:00
parent 399d0923be
commit 6a8a27a74e
34 changed files with 1940 additions and 131 deletions
+87 -2
View File
@@ -61,7 +61,7 @@ def test_streamlit_apptest_core_pages_use_synthetic_fixture_db(tmp_path, monkeyp
"월정산": "월간 핵심 KPI",
}
for page, expected_text in page_expectations.items():
at = AppTest.from_file(str(app_path), default_timeout=10)
at = AppTest.from_file(str(app_path), default_timeout=30)
at.query_params["page"] = page
if page == "월정산":
at.query_params["month"] = "2026-06"
@@ -88,7 +88,7 @@ def test_streamlit_apptest_core_pages_use_synthetic_fixture_db(tmp_path, monkeyp
assert "최근 동기화: 2026-06-30T23:59:00+09:00" in body_text
assert "잔액: 1,250,000원" in body_text
assert "상태: 정상" in body_text
assert "자산 상세: 경고 없음" in body_text
assert "자산 상세: 경고 3건 / 제외 1건" in body_text
assert "월정산 결과 / Evidence" in body_text
assert "읽기 전용 근거 요약" in body_text
assert "이번 범위에는 월정산 close 저장/실행이 포함되지 않습니다" in body_text
@@ -130,3 +130,88 @@ def test_streamlit_apptest_core_pages_use_synthetic_fixture_db(tmp_path, monkeyp
assert "/home/" not in body_text
assert "raw_payload" not in body_text
assert "🔒 읽기 전용" in body_text
def _dashboard_body(at):
return "\\n".join(str(item.value) for item in list(at.text) + list(at.markdown) + list(at.caption))
def test_authenticated_asset_and_monthly_pages_render_evidence_details(tmp_path, monkeypatch):
fixture = tmp_path / "fixture.sqlite3"
create_ci_fixture_db(fixture)
monkeypatch.setenv("JARCA_LEDGER_DB_PATH", str(fixture))
monkeypatch.setenv(authentication.ADMIN_ID_ENV, "test-admin")
monkeypatch.setenv(authentication.ADMIN_PASSWORD_ENV, "test-password")
monkeypatch.setenv(authentication.SIGNING_SECRET_ENV, "s" * 64)
settings = authentication.load_auth_settings()
token = authentication.issue_persistent_token(settings, remember_me=False).value
monkeypatch.setattr(authentication, "_request_cookie", lambda: token)
app_path = Path(__file__).resolve().parents[1] / "dashboard" / "app.py"
for page in ("자산/마감", "월정산"):
at = AppTest.from_file(str(app_path), default_timeout=30)
at.query_params["page"] = page
if page == "월정산":
at.query_params["month"] = "2026-06"
at.run()
assert not at.exception
body = _dashboard_body(at)
if page == "월정산":
assert "missing_verified_exact_valuation" in body
assert "acct_" in body
assert "제외 상세" in body
assert "source_note" not in body
assert "memo" not in body
def test_authenticated_dashboard_all_pages_are_no_write(tmp_path, monkeypatch):
fixture = tmp_path / "fixture.sqlite3"
create_ci_fixture_db(fixture)
monkeypatch.setenv("JARCA_LEDGER_DB_PATH", str(fixture))
monkeypatch.setenv(authentication.ADMIN_ID_ENV, "test-admin")
monkeypatch.setenv(authentication.ADMIN_PASSWORD_ENV, "test-password")
monkeypatch.setenv(authentication.SIGNING_SECRET_ENV, "s" * 64)
settings = authentication.load_auth_settings()
token = authentication.issue_persistent_token(settings, remember_me=False).value
monkeypatch.setattr(authentication, "_request_cookie", lambda: token)
app_path = Path(__file__).resolve().parents[1] / "dashboard" / "app.py"
pages = ["월정산", "요약", "자산/마감", "거래내역", "확인필요 큐", "미분류", "분류 규칙", "카테고리", "계좌", "Import"]
import sqlite3
def data_version():
with sqlite3.connect(fixture) as conn:
return conn.execute("PRAGMA data_version").fetchone()[0]
before_data_version = data_version()
for page in pages:
at = AppTest.from_file(str(app_path), default_timeout=30)
at.query_params["page"] = page
if page == "월정산":
at.query_params["month"] = "2026-06"
at.run()
assert not at.exception, (page, at.exception)
assert data_version() == before_data_version
def test_authenticated_dashboard_missing_db_is_stable_and_does_not_initialize(tmp_path, monkeypatch):
db_path = tmp_path / "missing" / "nested" / "ledger.sqlite3"
monkeypatch.setenv("JARCA_LEDGER_DB_PATH", str(db_path))
monkeypatch.setenv(authentication.ADMIN_ID_ENV, "test-admin")
monkeypatch.setenv(authentication.ADMIN_PASSWORD_ENV, "test-password")
monkeypatch.setenv(authentication.SIGNING_SECRET_ENV, "s" * 64)
settings = authentication.load_auth_settings()
token = authentication.issue_persistent_token(settings, remember_me=False).value
monkeypatch.setattr(authentication, "_request_cookie", lambda: token)
app_path = Path(__file__).resolve().parents[1] / "dashboard" / "app.py"
for page in ["월정산", "요약", "자산/마감", "거래내역", "확인필요 큐", "미분류", "분류 규칙", "카테고리", "계좌", "Import"]:
at = AppTest.from_file(str(app_path), default_timeout=30)
at.query_params["page"] = page
at.run()
assert not at.exception, (page, at.exception)
body = _dashboard_body(at) + "\n".join(str(item.value) for item in at.error)
assert "Ledger DB를 사용할 수 없습니다" in body
assert not db_path.exists()
assert not db_path.parent.exists()