aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl/test_ledger/test_lm_tx_entries.py
blob: 03c6e0200eae186ba556278e7c9e9e398b338739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import annotations

from typing import TYPE_CHECKING

from generalresearch.models.thl.ledger import (
    LedgerEntry,
)

if TYPE_CHECKING:
    from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
    from generalresearch.models.thl.ledger import (
        LedgerTransaction,
    )


class TestLedgerEntryManager:

    def test_get_tx_entries_by_tx(
        self, ledger_tx: LedgerTransaction, ledger_manager: LedgerManager
    ):
        # First confirm the Ledger TX exists with 2 Entries
        res = ledger_manager.get_tx_by_id(transaction_id=ledger_tx.id)
        assert len(res.entries) == 2

        tx_entries = ledger_manager.get_tx_entries_by_tx(transaction=ledger_tx)
        assert len(tx_entries) == 2

        assert res.entries == tx_entries
        assert isinstance(tx_entries[0], LedgerEntry)

    def test_get_tx_entries_by_txs(
        self, ledger_tx: LedgerTransaction, ledger_manager: LedgerManager
    ):
        # First confirm the Ledger TX exists with 2 Entries
        res = ledger_manager.get_tx_by_id(transaction_id=ledger_tx.id)
        assert len(res.entries) == 2

        tx_entries = ledger_manager.get_tx_entries_by_txs(transactions=[ledger_tx])
        assert len(tx_entries) == 2

        assert res.entries == tx_entries
        assert isinstance(tx_entries[0], LedgerEntry)