conftest.py 746 Bytes
Newer Older
1
2
3
from pathlib import Path
import pytest

4
from sqlalchemy import create_engine
5
6
7

from pytest_sa_pg import db

8
9
10
11
12
13
14
from tshistory.schema import (
    init_schemas,
    register_schema,
    reset_schemas,
    tsschema
)

15
from tshistory_supervision.tsio import timeseries
16

17

18
19
20
21
22
23
24
25
DATADIR = Path(__file__).parent / 'test' / 'data'


@pytest.fixture(scope='session')
def engine(request):
    port = 5433
    db.setup_local_pg_cluster(request, DATADIR, port)
    uri = 'postgresql://localhost:{}/postgres'.format(port)
26
27
    tsschema()
    tsschema('tsh-automatic')
28
    e = create_engine(uri)
29
    reset_schemas(e)
30
    init_schemas(e)
31
32
33
34
35
    yield e


@pytest.fixture(scope='session')
def tsh(request, engine):
36
    return timeseries()