Coverage for databases/tests/conftest.py: 100%
22 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1import os
3import pytest
4from syrupy.assertion import SnapshotAssertion
6import prisma
7from prisma import Prisma
8from prisma._compat import model_parse_json
9from lib.testing.shared_conftest import *
10from lib.testing.shared_conftest.async_client import *
12from ..utils import (
13 RAW_QUERIES_MAPPING,
14 RawQueries,
15 DatabaseConfig,
16 AmberSharedExtension,
17)
19prisma.register(Prisma())
22# TODO: better error messages for invalid state
23@pytest.fixture(name='database')
24def database_fixture() -> str:
25 return os.environ['PRISMA_DATABASE']
28@pytest.fixture(name='raw_queries')
29def raw_queries_fixture(database: str) -> RawQueries:
30 return RAW_QUERIES_MAPPING[database]
33@pytest.fixture(name='config', scope='session')
34def config_fixture() -> DatabaseConfig:
35 return model_parse_json(DatabaseConfig, os.environ['DATABASE_CONFIG'])
38@pytest.fixture()
39def snapshot(snapshot: SnapshotAssertion) -> SnapshotAssertion:
40 return snapshot.use_extension(AmberSharedExtension)