You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.1 KiB

from datetime import date
from decimal import Decimal
import pytest
from finance.models import Account, Category, Tag, Transaction
pytestmark = pytest.mark.django_db
def test_ungrouped_categories_and_transaction_links_remain_valid():
account = Account.objects.create(name="Synthetic bank", kind="BANK")
category = Category.objects.create(name="Synthetic Food", kind="EXPENSE")
transaction = Transaction.objects.create(
account=account,
amount=Decimal("-10.00"),
posting_date=date(2026, 9, 14),
kind="EXPENSE",
category=category,
)
category.refresh_from_db()
assert category.group_id is None
assert transaction.category_id == category.pk
def test_tags_can_be_attached_without_changing_category():
account = Account.objects.create(name="Synthetic bank", kind="BANK")
transaction = Transaction.objects.create(
account=account,
amount=Decimal("-10.00"),
posting_date=date(2026, 9, 14),
kind="EXPENSE",
)
tag = Tag.objects.create(name="Synthetic Tax")
transaction.tags.add(tag)
assert list(transaction.tags.all()) == [tag]