remove legacy systems

This commit is contained in:
SowinskiBraeden committed 2026-06-28 10:51:59 -07:00
1 parent 9e6f5bd3ef
commit 79c638b8fa
12 files changed
+191 -1188

No files matched your search

+29 -60
View File
@@ -1,15 +1,12 @@
from pathlib import Path
import tempfile
import unittest
import app as app_module
from charts import player_session_series
from services import (
build_leaderboard,
build_session_summaries,
pending_payout_carry_items,
prunable_empty_session_ids,
)
from storage import load_events, write_events
from utils import session_sort_key
@@ -189,7 +186,7 @@ class AccountingTests(unittest.TestCase):
self.assertEqual(entry.paid_out_cents, 0)
self.assertEqual(entry.payout_status, "settled")
def test_admin_can_apply_pending_payout_carry_in_to_open_session(self):
def test_pending_payout_carry_in_preserves_poker_investment(self):
rows = [
event("s1", "2026-01-01", "", "session_open", 0, 1),
event("s1", "2026-01-01", "A", "buyin", 10, 2),
@@ -200,37 +197,19 @@ class AccountingTests(unittest.TestCase):
event("s2", "2026-01-02", "A", "buyin", 10, 7),
]
with tempfile.TemporaryDirectory() as tmpdir:
data_path = Path(tmpdir) / "entries.csv"
write_events(data_path, rows)
original_path = app_module.app.config["DATA_PATH"]
app_module.app.config["DATA_PATH"] = data_path
sessions = build_session_summaries(rows)
self.assertEqual(
pending_payout_carry_items(sessions),
[{"player_name": "A", "amount_cents": cents(5)}],
)
try:
sessions = build_session_summaries(load_events(data_path))
self.assertEqual(
pending_payout_carry_items(sessions),
[{"player_name": "A", "amount_cents": cents(5)}],
)
with app_module.app.test_client() as client:
with client.session_transaction() as flask_session:
flask_session["is_admin"] = True
response = client.post(
"/admin/apply-payout-carry-in",
data={"session_id": "s2", "player_name": "A"},
)
finally:
app_module.app.config["DATA_PATH"] = original_path
self.assertEqual(response.status_code, 302)
updated_sessions = build_session_summaries(load_events(data_path))
target = next(s for s in updated_sessions if s.session_id == "s2")
target_entry = target.entries[0]
self.assertEqual(target_entry.payout_carry_in_cents, cents(5))
self.assertEqual(target_entry.invested_cents, cents(10))
self.assertEqual(target_entry.current_due_to_player_cents, cents(5))
rows.append(event("s2", "2026-01-02", "A", "payout_carry_in", 5, 8))
updated_sessions = build_session_summaries(rows)
target = next(s for s in updated_sessions if s.session_id == "s2")
target_entry = target.entries[0]
self.assertEqual(target_entry.payout_carry_in_cents, cents(5))
self.assertEqual(target_entry.invested_cents, cents(10))
self.assertEqual(target_entry.current_due_to_player_cents, cents(5))
def test_same_day_sessions_sort_by_session_sequence(self):
rows = [
@@ -248,7 +227,7 @@ class AccountingTests(unittest.TestCase):
["Mar 21, 2026 · S1", "Mar 21, 2026 · S2"],
)
def test_admin_prunes_only_empty_marker_sessions(self):
def test_prunable_empty_sessions_excludes_played_sessions(self):
rows = [
event("empty-1", "2026-01-01", "", "session_open", 0, 1),
event("empty-1", "2026-01-01", "", "session_close", 0, 2),
@@ -258,31 +237,21 @@ class AccountingTests(unittest.TestCase):
event("played-1", "2026-01-02", "", "session_close", 0, 6),
]
with tempfile.TemporaryDirectory() as tmpdir:
data_path = Path(tmpdir) / "entries.csv"
write_events(data_path, rows)
original_path = app_module.app.config["DATA_PATH"]
app_module.app.config["DATA_PATH"] = data_path
sessions = build_session_summaries(rows)
prunable_ids = prunable_empty_session_ids(rows, sessions)
self.assertEqual(prunable_ids, {"empty-1"})
try:
with app_module.app.test_client() as client:
with client.session_transaction() as flask_session:
flask_session["is_admin"] = True
response = client.post("/admin/prune-empty-sessions")
finally:
app_module.app.config["DATA_PATH"] = original_path
self.assertEqual(response.status_code, 302)
remaining = load_events(data_path)
self.assertEqual(
{row["session_id"] for row in remaining},
{"played-1"},
)
self.assertEqual(
[row["event_type"] for row in remaining],
["session_open", "buyin", "cashout", "session_close"],
)
remaining = [
row
for row in rows
if (row["session_id"].strip() or row["session_date"].strip())
not in prunable_ids
]
self.assertEqual({row["session_id"] for row in remaining}, {"played-1"})
self.assertEqual(
[row["event_type"] for row in remaining],
["session_open", "buyin", "cashout", "session_close"],
)
if __name__ == "__main__":