add unit test for error handling in build_config()

This commit is contained in:
Stefan Allius
2025-05-07 23:42:55 +02:00
parent e1f0aac9bf
commit fc93930656
3 changed files with 17 additions and 3 deletions

View File

@@ -0,0 +1 @@
mqtt.port = ":1883"

View File

@@ -123,6 +123,17 @@ class TestServerClass:
assert logging.getLogger('hypercorn.access').level == logging.INFO
assert logging.getLogger('hypercorn.error').level == logging.INFO
def test_build_config_error(self, caplog):
s = self.FakeServer()
s.src_dir = 'app/src/'
s.toml_config = 'app/tests/cnf/invalid_config.toml'
with caplog.at_level(logging.ERROR):
s.build_config()
assert "Can't read from app/tests/cnf/invalid_config.toml" in caplog.text
assert "Key 'port' error:" in caplog.text
class TestHypercornLogHndl:
class FakeServer(Server):
def __init__(self):