Esempio n. 1
0
    def __init__(self,
                 source_root: str = None,
                 resource_dir: str = None,
                 log_dir: str = None,
                 log_file: str = None):

        self._source_dir = source_root \
            if source_root else os.environ.get('SOURCE_ROOT', dirname(__file__))
        assert os.path.exists(
            self._source_dir
        ), f"Unable to find the source dir: {self._source_dir}"

        self._resource_dir = resource_dir \
            if resource_dir else os.environ.get('RESOURCE_DIR', f"{self._source_dir}/resources")
        assert os.path.exists(
            self._resource_dir
        ), f"Unable to find the resources dir: {self._resource_dir}"

        self._log_dir = log_dir \
            if log_dir else os.environ.get('LOG_DIR', f"{self._resource_dir}/log")
        assert os.path.exists(
            self._log_dir), f"Unable to find the log dir: {self._log_dir}"

        self._log_file = log_file \
            if log_file else f"{self._log_dir}/application.log"
        assert log_init(
            self._log_file), f"Unable to create logger: {self._log_file}"

        self._app_properties = Properties(load_dir=self._resource_dir)
        log.info(self)
Esempio n. 2
0
 def __init__(self, app_name: str):
     # Invoke the super constructor without source_dir parameter to skip creation of log and properties
     super().__init__(app_name,
                      self.VERSION,
                      self.USAGE,
                      source_dir=dirname(__file__))
Esempio n. 3
0
    @author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
      @site: https://github.com/yorevs/hspylib
   @license: MIT - Please refer to <https://opensource.org/licenses/MIT>

   Copyright 2021, HSPyLib team
"""

import logging as log
import os
import sys
import unittest

from hspylib.core.config.app_config import AppConfigs
from hspylib.core.tools.commons import dirname

TEST_DIR = dirname(__file__)


class TestAppConfig(unittest.TestCase):

    # Setup tests
    def setUp(self):
        resource_dir = '{}/resources'.format(TEST_DIR)
        os.environ['ACTIVE_PROFILE'] = "test"
        self.configs = AppConfigs(
            source_root=TEST_DIR, resource_dir=resource_dir, log_dir=resource_dir
        )
        self.assertIsNotNone(self.configs)
        self.assertIsNotNone(AppConfigs.INSTANCE)
        log.info(self.configs)
        os.environ['TEST_OVERRIDDEN_BY_ENVIRON'] = 'yes its overridden'
Esempio n. 4
0
 def test_should_instantiate_configs(self):
     Application('App-test', source_dir=dirname(__file__))
     self.assertTrue(hasattr(AppConfigs, 'INSTANCE'))
Esempio n. 5
0
 def __init__(self, app_name: str):
     super().__init__(app_name, self.VERSION, self.USAGE, dirname(__file__))
     self.firebase = Firebase()
Esempio n. 6
0
 def __init__(self, app_name: str):
     super().__init__(app_name, self.VERSION, self.USAGE, dirname(__file__))
     self.cfman = None
Esempio n. 7
0
 def __init__(self, app_name: str):
     super().__init__(app_name, self.VERSION, source_dir=dirname(__file__))
Esempio n. 8
0
 def __init__(self, app_name: str):
     super().__init__(app_name, read_version(), self.USAGE,
                      dirname(__file__))
     self.main_view = QtApplication(MainQtView)
Esempio n. 9
0
 def __init__(self, app_name: str):
     super().__init__(app_name, self.VERSION, self.USAGE, dirname(__file__))
     self.vault = Vault()