def setUp(self): self.log_file = self._log_path("win_service") self.settings_file = os.path.join(CWD, "settings_test.py") config = dict(self.CONFIG) config["LOG_PATH"] = self.log_file Config.store(self.settings_file, **config) subprocess_check_call([ sys.executable, "wrun_server.py", "install", self.SERVICE_NAME, self.settings_file ])
def setUp(self): self.log_file = self._log_path("win_service") self.settings_file = os.path.join(CWD, "settings_test.py") Config.store(self.settings_file, LOG_PATH=self.log_file, COLLECT_STDERR=True, EXECUTABLE_PATH=EXECUTABLE_PATH, HOST="localhost", PORT=self.PORT) subprocess_check_call([ sys.executable, "wrun_server.py", "install", self.SERVICE_NAME, self.settings_file ])
def setUp(self): log_path_1 = self._log_path("server_1") log_path_2 = self._log_path("server_2") self.settings_file_1 = os.path.join(CWD, "settings_test_1.py") Config.store( self.settings_file_1, LOG_PATH=log_path_1, EXECUTABLE_PATH=EXECUTABLE_PATH, HOST="localhost", PORT=3333) self.settings_file_2 = os.path.join(CWD, "settings_test_2.py") Config.store( self.settings_file_2, LOG_PATH=log_path_2, EXECUTABLE_PATH=self.EXECUTABLE_PATH_2, HOST="localhost", PORT=3334) self.proc_1 = subprocess.Popen([sys.executable, "wrun_server.py", "run", self.settings_file_1]) self.proc_2 = subprocess.Popen([sys.executable, "wrun_server.py", "run", self.settings_file_2])
def setUp(self): self.log_path_1 = self._log_path("win_service_1") self.log_path_2 = self._log_path("win_service_2") self.settings_file_1 = os.path.join(CWD, "settings_test_1.py") Config.store(self.settings_file_1, LOG_PATH=self.log_path_1, EXECUTABLE_PATH=EXECUTABLE_PATH, HOST="localhost", PORT=3333) self.settings_file_2 = os.path.join(CWD, "settings_test_2.py") Config.store(self.settings_file_2, LOG_PATH=self.log_path_2, EXECUTABLE_PATH=self.EXECUTABLE_PATH_2, HOST="localhost", PORT=3334) subprocess_check_call([ sys.executable, "wrun_server.py", "install", "TestWRUN_1", self.settings_file_1 ]) subprocess_check_call([ sys.executable, "wrun_server.py", "install", "TestWRUN_2", self.settings_file_2 ])
def test_log_dictconfig(self): Config.store(self.config_file, LOG_DICTCONFIG={ "version": 1, 'disable_existing_loggers': True, 'formatters': { 'standard': { 'format': '[%(levelname)s] %(name)s: %(message)s' }, }, 'handlers': { 'default': { 'level': 'DEBUG', 'formatter': 'standard', 'class': 'logging.FileHandler', 'filename': self.log_file.replace('\\', '/'), 'mode': 'a', }, }, 'loggers': { '': { 'handlers': ['default'], 'level': 'DEBUG', 'propagate': True }, 'wrun': { 'handlers': ['default'], 'level': 'DEBUG', 'propagate': True }, } }) config = Config(self.config_file) self.assertTrue(config.LOG_DICTCONFIG) self.assertLogContains("[INFO] wrun: settings \"{\'")
def test_xor_on_log_settings(self): Config.store(self.config_file, LOG_PATH=self.log_file, LOG_FILECONFIG=self.log_fileconfig) self.assertRaises(AssertionError, Config, self.config_file)
def test_log_fileconfig(self): Config.store(self.config_file, LOG_FILECONFIG=self.log_fileconfig) config = Config(self.config_file) self.assertTrue(config.LOG_FILECONFIG) self.assertLogContains("INFO-wrun settings \"{\'")
def test_log_path(self): Config.store(self.config_file, LOG_PATH=self.log_file) config = Config(self.config_file) self.assertTrue(config.LOG_PATH) self.assertLogContains("INFO:wrun:settings")