Subscriptions belong to a company; BroV owns its Keychain token
- ops: subscriptions get a client (company) column (migrated in place); the brain fills it from «компания сага / для планеты»; /subs and «Весь план» group by company with per-company monthly totals; the company shows in agenda rows and the calendar. - BroV: the API token handed over in ops-token.import is saved by BroV itself, so the Keychain item belongs to BroV and macOS stops asking for the password. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,5 +105,34 @@ class Brain(unittest.TestCase):
|
||||
self.assertEqual(o.routines()[0]["every_days"], 30)
|
||||
|
||||
|
||||
class Company(unittest.TestCase):
|
||||
def test_sub_company_and_totals(self):
|
||||
o = fresh()
|
||||
o.add_sub("Claude Code", 20, "2026-10-25", currency="USD", client="Saga")
|
||||
o.add_sub("Домен", 1200, "2026-11-15", period="year")
|
||||
self.assertEqual(o.subs()[0]["client"], "saga")
|
||||
self.assertEqual(o.monthly_by_client(), {"saga": {"USD": 20.0}, "": {"RUB": 100.0}})
|
||||
text = fmt.subs(o.subs(), o.monthly_by_client(), date(2026, 10, 10))
|
||||
self.assertIn("<b>Сага</b>", text)
|
||||
self.assertIn("Без компании", text)
|
||||
plan = {"actions": [{"op": "update_sub", "id": 2, "client": "home"}]}
|
||||
brain.apply_plan(o, plan)
|
||||
self.assertEqual(o.sub(2)["client"], "home")
|
||||
|
||||
def test_old_database_gets_the_column(self):
|
||||
import sqlite3, tempfile
|
||||
path = tempfile.mktemp(suffix=".db")
|
||||
con = sqlite3.connect(path)
|
||||
con.execute("CREATE TABLE subscriptions (id INTEGER PRIMARY KEY, name TEXT NOT NULL, amount REAL NOT NULL DEFAULT 0, "
|
||||
"currency TEXT NOT NULL DEFAULT 'RUB', period TEXT NOT NULL DEFAULT 'month', every INTEGER NOT NULL DEFAULT 1, "
|
||||
"next_date TEXT NOT NULL, remind_days INTEGER NOT NULL DEFAULT 3, notes TEXT NOT NULL DEFAULT '', "
|
||||
"active INTEGER NOT NULL DEFAULT 1)")
|
||||
con.execute("INSERT INTO subscriptions (name, next_date) VALUES ('old', '2026-11-01')")
|
||||
con.commit(); con.close()
|
||||
o = Ops(connect(path))
|
||||
self.assertEqual(o.subs()[0]["client"], "")
|
||||
os.remove(path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user