conftest.py 842 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
9
10
11
12
13
14
from tshistory.schema import (
    init_schemas,
    register_schema,
    reset_schemas,
    tsschema
)

15
16
from tshistory_supervision.tsio import TimeSerie

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
30
    reset_schemas(e)
    init_schemas(e, MetaData())
31
32
33
34
35
    yield e


@pytest.fixture(scope='session')
def tsh(request, engine):
36
37
38
39
    tsh = TimeSerie()
    tsh._testing = True
    tsh.auto_store._testing = True
    return tsh