Skip to content

Commit 2bd8a8a

Browse files
committed
❇️ [refactor][backend] account crud tests
1 parent c87a5ad commit 2bd8a8a

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

backend/kayman/tests/crud/test_account.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
update_accounts,
1818
)
1919
from kayman.schemas.account import Account, AccountCreate
20-
from kayman.tests.factories import AccountFactory, TransactionFactory
20+
from kayman.tests.factories import AccountFactory, CurrencyFactory, TransactionFactory
2121

2222

2323
def test_create_accounts_1_account(session: Session, session_2: Session):
24-
account = AccountCreate.model_validate(AccountFactory.build())
24+
currency = CurrencyFactory()
25+
account = AccountCreate.model_validate(
26+
AccountFactory.build(currency_code=currency.code)
27+
)
2528
db_account = create_accounts(session, [account])[0]
2629
db_read_account = read_account(session_2, db_account.id)
2730

@@ -33,9 +36,10 @@ def test_create_accounts_1_account(session: Session, session_2: Session):
3336

3437

3538
def test_create_accounts_n_accounts(session: Session):
39+
currency = CurrencyFactory()
3640
accounts = [
3741
AccountCreate.model_validate(account)
38-
for account in AccountFactory.build_batch(10)
42+
for account in AccountFactory.build_batch(10, currency_code=currency.code)
3943
]
4044
db_accounts = create_accounts(session, accounts)
4145

@@ -53,7 +57,10 @@ def test_create_accounts_empty(session: Session):
5357

5458

5559
def test_create_accounts_no_commit(session: Session, session_2: Session):
56-
account = AccountCreate.model_validate(AccountFactory.build())
60+
currency = CurrencyFactory()
61+
account = AccountCreate.model_validate(
62+
AccountFactory.build(currency_code=currency.code)
63+
)
5764

5865
# The account should be created in the session
5966
session_account = create_accounts(session, [account], commit=False)[0]
@@ -217,7 +224,10 @@ def test_read_accounts_for_update(session: Session):
217224

218225
def test_update_accounts(session: Session):
219226
accounts = AccountFactory.create_batch(10)
220-
account_updates = AccountFactory.build_batch(10)
227+
account_updates = [
228+
AccountFactory.build(currency_code=account.currency_code)
229+
for account in accounts
230+
]
221231

222232
account_ids = []
223233
for account, account_update in zip(accounts, account_updates, strict=True):

0 commit comments

Comments
 (0)