Controller/tests/fixtures.py

39 lines
1,011 B
Python

# coding=utf-8
from typing import Dict
from importlib_resources import files
import os
from tsgrain_controller import io, config, models
DIR_TESTFILES = str(files('tests.testfiles').joinpath(''))
FILE_CFG = os.path.join(DIR_TESTFILES, 'tsgrain.toml')
CMD_SET_DATE = os.path.join(DIR_TESTFILES, 'set_date')
CMD_SET_TZ = os.path.join(DIR_TESTFILES, 'set_tz')
CMD_GET_TZ = os.path.join(DIR_TESTFILES, 'get_tz')
CMD_ERR = os.path.join(DIR_TESTFILES, 'set_err')
class TestingIo(io.Io):
def __init__(self):
super().__init__()
self.outputs: Dict[str, bool] = dict()
def write_output(self, key: str, val: bool):
self.outputs[key] = val
class TestingApp(models.AppInterface):
def __init__(self, db_file=''):
self.auto = False
self.cfg = config.Config(FILE_CFG)
self.cfg.load_file(False)
self.cfg.db_path = db_file
def get_auto_mode(self) -> bool:
return self.auto
def get_cfg(self) -> config.Config:
return self.cfg