From d2deb5b03891ccf73194bc3bb5e032d9a4529d98 Mon Sep 17 00:00:00 2001 From: Max Fischer Date: Tue, 23 Mar 2021 11:40:48 +0100 Subject: [PATCH] added test for invalid extensions --- cobald_tests/daemon/config/test_python.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cobald_tests/daemon/config/test_python.py b/cobald_tests/daemon/config/test_python.py index 540cc98e..ec540181 100644 --- a/cobald_tests/daemon/config/test_python.py +++ b/cobald_tests/daemon/config/test_python.py @@ -1,5 +1,5 @@ import tempfile -import os +import pytest from cobald.daemon.config.python import load_configuration @@ -27,3 +27,12 @@ def test_load_pyconfig_many(): modules.append((ident, load_configuration(test_file.name))) for ident, module in modules: assert ident == module.identifier + + +@pytest.mark.parametrize("extension", [".pyi", ".yml", ""]) +def test_load_pyconfig_invalid(extension): + with pytest.raises(ValueError): + with tempfile.NamedTemporaryFile(mode="w+", suffix=extension) as test_file: + test_file.write(module_content("'unused'")) + test_file.flush() + _ = load_configuration(test_file.name)