From a7b3bb6dc4ca472e016ec2ebba90c8115d1e90da Mon Sep 17 00:00:00 2001 From: TAC Date: Tue, 22 Sep 2020 22:26:25 +0900 Subject: [PATCH] Fix keep running if no config files --- onamazu/onamazu.py | 2 +- tests/test_reload_conf.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/onamazu/onamazu.py b/onamazu/onamazu.py index 12330c2..1e0962a 100644 --- a/onamazu/onamazu.py +++ b/onamazu/onamazu.py @@ -22,7 +22,7 @@ def __load_config(self): self.logger.info(f'config_map={config_map}') if len(config_map) == 0: - raise Exception("No config file found. Please see README.md") + self.logger.warning(f"No config files ({config.ConfigFileName}) are found. Please see README.md") return config_map diff --git a/tests/test_reload_conf.py b/tests/test_reload_conf.py index 1a61c54..866551b 100644 --- a/tests/test_reload_conf.py +++ b/tests/test_reload_conf.py @@ -8,6 +8,15 @@ from onamazu.watcher import NamazuEvent +def test_return_empty_when_no_config_file(): + o = ONamazu(ct.ROOT_DIR, 60) + o.event_handler = MagicMock(name="event_handler") + o.click() + o.stop() + + o.event_handler.assert_not_called() + + class TestReload: def test_reload_on_create(self): ct.place_config_file("", {"pattern": "*.csv"})