1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import os
- import pytest
- import shutil
- import sys
- from tempfile import mkstemp
-
- from pyheatpump import DB
- from pyheatpump.models import *
- from pyheatpump.config import config
-
- pytest_plugins = "pytester"
-
- @pytest.fixture(scope="module")
- def set_test_db():
- _, tmpdb = mkstemp(suffix='.db', dir=os.getcwd(), )
- print(f'Will store database in {tmpdb}')
- config['heatpump']['database'] = tmpdb
- assert DB.initialize(os.path.join(os.getcwd(), './db/pyheatpump.sql'))
-
- DB.sqlf(os.path.join(os.getcwd(), 'db/test_variables.sql'))
-
- DB.sqlf(os.path.join(os.getcwd(), 'db/test_variable_values.sql'))
-
- DB.sqlf(os.path.join(os.getcwd(), 'db/test_variable_values_wo_time.sql'))
-
- yield
-
- os.unlink(tmpdb)
-
-
- @pytest.fixture(scope="module")
- def set_db_values():
- _, tmpdb = mkstemp(suffix='.db', dir=os.getcwd(), )
- db_file = "./db/pyheatpump.db"
- shutil.copy(db_file, tmpdb)
- config['heatpump']['database'] = tmpdb
-
- yield
- os.unlink(tmpdb)
-
-
- @pytest.fixture
- def var_types():
- return VariableType.getall()
|