conftest.py 686 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
from tshistory.schema import tsschema
9

10
from tshistory_supervision.tsio import timeseries
11

12

13
14
15
16
17
18
19
20
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)
21
22
    sch1 = tsschema()
    sch2 = tsschema('tsh-automatic')
23
    e = create_engine(uri)
24
25
    sch1.create(e)
    sch2.create(e)
26
27
28
29
30
    yield e


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