conftest.py 736 Bytes
Newer Older
1
2
3
4
5
6
7
from pathlib import Path
import pytest

from sqlalchemy import create_engine, MetaData

from pytest_sa_pg import db

8
from tshistory_supervision.schema import init, reset
9
10
11
12
13
14
15
16
17
18
19
20
from tshistory_supervision.tsio import TimeSerie

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)
    e = create_engine(uri)
    meta = MetaData()
Aurélien Campéas's avatar
Aurélien Campéas committed
21
22
    reset(e)
    init(e, meta)
23
24
25
26
27
    yield e


@pytest.fixture(scope='session')
def tsh(request, engine):
28
29
30
31
    tsh = TimeSerie()
    tsh._testing = True
    tsh.auto_store._testing = True
    return tsh