diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-30 12:53:01 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-30 12:53:01 +0200 |
| commit | 2db11aa5d34766e4d23ccc308c57c470b6aa6dba (patch) | |
| tree | aa30c498fc23da90a31c72024146066c7dd8223f /tests | |
| parent | a257b55fe44535af7f8f9197c018154c2441f9ab (diff) | |
| download | firefly-cli-2db11aa5d34766e4d23ccc308c57c470b6aa6dba.tar.gz firefly-cli-2db11aa5d34766e4d23ccc308c57c470b6aa6dba.zip | |
tx add: auto-create categories instead of requiring them
Pass --category straight to Firefly III as category_name; the API
creates the category if it does not exist, matching --tags behavior.
Drops the resolver lookup that turned an unknown category into a hard
error. Accounts still resolve strictly (real money).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_commands_transaction.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unit/test_commands_transaction.py b/tests/unit/test_commands_transaction.py index db187b7..7301002 100644 --- a/tests/unit/test_commands_transaction.py +++ b/tests/unit/test_commands_transaction.py @@ -55,6 +55,18 @@ class TestTxAdd(unittest.TestCase): self.assertEqual(split["type"], "transfer") self.assertEqual(split["tags"], ["food", "fun"]) + def test_category_passed_raw_not_resolved(self): + # Category name goes straight to Firefly (auto-creates); resolver untouched. + ctx, client, resolver = make_ctx() + resolver.account.side_effect = lambda n: {"id": "1", "type": "asset", "name": n} + client.request.return_value = {"data": {"id": "1", "attributes": {}}} + args = MagicMock(amount="5", source="A", dest="B", desc=None, date=None, + category="Brand New Cat", tags=None, type="withdrawal") + tx.cmd_add(args, ctx) + split = client.request.call_args[1]["body"]["transactions"][0] + self.assertEqual(split["category_name"], "Brand New Cat") + resolver.category.assert_not_called() + class TestTxList(unittest.TestCase): def test_list_passes_date_params(self): ctx, client, _ = make_ctx() |
