Coverage for databases/sync_tests/conftest.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-08-27 18:25 +0000

1from __future__ import annotations 

2 

3import os 

4 

5import pytest 

6from syrupy.assertion import SnapshotAssertion 

7 

8from prisma._compat import model_parse_json 

9from lib.testing.shared_conftest import * 

10from lib.testing.shared_conftest.sync_client import * 

11 

12from ..utils import ( 

13 RAW_QUERIES_MAPPING, 

14 RawQueries, 

15 DatabaseConfig, 

16 AmberSharedExtension, 

17) 

18 

19# TODO: the async tests conftest.py is imported somehow which breaks this... 

20# prisma.register(Prisma()) 

21 

22 

23# TODO: better error messages for invalid state 

24@pytest.fixture(name='database') 

25def database_fixture() -> str: 

26 return os.environ['PRISMA_DATABASE'] 

27 

28 

29@pytest.fixture(name='raw_queries') 

30def raw_queries_fixture(database: str) -> RawQueries: 

31 return RAW_QUERIES_MAPPING[database] 

32 

33 

34@pytest.fixture(name='config', scope='session') 

35def config_fixture() -> DatabaseConfig: 

36 return model_parse_json(DatabaseConfig, os.environ['DATABASE_CONFIG']) 

37 

38 

39@pytest.fixture() 

40def snapshot(snapshot: SnapshotAssertion) -> SnapshotAssertion: 

41 return snapshot.use_extension(AmberSharedExtension)