aboutsummaryrefslogtreecommitdiff
path: root/test_utils/managers/ledger/conftest.py
blob: ce8348e85d23d4041a1036531fdcc41ad5372f4f (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from __future__ import annotations

import pytest

from generalresearch.managers.base import Permission
from generalresearch.managers.thl.ledger_manager.ledger import (
    LedgerAccountManager,
    LedgerManager,
    LedgerTransactionManager,
)
from generalresearch.managers.thl.ledger_manager.thl_ledger import (
    ThlLedgerManager,
)
from generalresearch.pg_helper import PostgresConfig
from generalresearch.redis_helper import RedisConfig

# --- Ledger ---


@pytest.fixture(scope="session")
def ledger_manager(
    thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig
) -> LedgerManager:

    return LedgerManager(
        pg_config=thl_web_rw,
        permissions=[
            Permission.CREATE,
            Permission.READ,
            Permission.UPDATE,
            Permission.DELETE,
        ],
        testing=True,
        redis_config=thl_redis_config,
    )


@pytest.fixture(scope="session")
def ledger_tx_manager(
    thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig
) -> LedgerTransactionManager:
    assert thl_web_rw.dsn.path
    assert "/unittest-" in thl_web_rw.dsn.path

    from generalresearch.managers.thl.ledger_manager.ledger import (
        LedgerTransactionManager,
    )

    return LedgerTransactionManager(
        pg_config=thl_web_rw,
        permissions=[Permission.CREATE, Permission.READ],
        testing=True,
        redis_config=thl_redis_config,
    )


@pytest.fixture(scope="session")
def ledger_account_manager(
    thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig
) -> LedgerAccountManager:
    assert thl_web_rw.dsn.path
    assert "/unittest-" in thl_web_rw.dsn.path

    from generalresearch.managers.thl.ledger_manager.ledger import (
        LedgerAccountManager,
    )

    return LedgerAccountManager(
        pg_config=thl_web_rw,
        permissions=[Permission.CREATE, Permission.READ],
        testing=True,
        redis_config=thl_redis_config,
    )


# --- THL Ledger ---


@pytest.fixture(scope="session")
def thl_ledger_manager(
    thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig
) -> ThlLedgerManager:

    return ThlLedgerManager(
        pg_config=thl_web_rw,
        permissions=[
            Permission.CREATE,
            Permission.READ,
            Permission.UPDATE,
            Permission.DELETE,
        ],
        testing=True,
        redis_config=thl_redis_config,
    )