Projet de remplacement du "RPiPasserelle" d'Otec.
Ви не можете вибрати більше 25 тем Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import os
  2. import pytest
  3. import shutil
  4. import sys
  5. from tempfile import mkstemp
  6. from pyheatpump import DB
  7. from pyheatpump.models import *
  8. from pyheatpump.config import config
  9. pytest_plugins = "pytester"
  10. @pytest.fixture(scope="module")
  11. def set_test_db():
  12. _, tmpdb = mkstemp(suffix='.db', dir=os.getcwd(), )
  13. print(f'Will store database in {tmpdb}')
  14. config['heatpump']['database'] = tmpdb
  15. assert DB.initialize(os.path.join(os.getcwd(), './db/pyheatpump.sql'))
  16. DB.sqlf(os.path.join(os.getcwd(), 'db/test_variables.sql'))
  17. DB.sqlf(os.path.join(os.getcwd(), 'db/test_variable_values.sql'))
  18. DB.sqlf(os.path.join(os.getcwd(), 'db/test_variable_values_wo_time.sql'))
  19. yield
  20. os.unlink(tmpdb)
  21. @pytest.fixture(scope="module")
  22. def set_db_values():
  23. _, tmpdb = mkstemp(suffix='.db', dir=os.getcwd(), )
  24. db_file = "./db/pyheatpump.db"
  25. shutil.copy(db_file, tmpdb)
  26. config['heatpump']['database'] = tmpdb
  27. yield
  28. os.unlink(tmpdb)
  29. @pytest.fixture
  30. def var_types():
  31. return VariableType.getall()