def test_include_yaml(): """Test include yaml.""" with patch_yaml_files({"test.yaml": "value"}): conf = "key: !include test.yaml" with io.StringIO(conf) as file: doc = yaml.load(file, Loader=SafeLineLoader) assert doc["key"] == "value" with patch_yaml_files({"test.yaml": None}): conf = "key: !include test.yaml" with io.StringIO(conf) as file: doc = yaml.load(file, Loader=SafeLineLoader) assert doc["key"] == {}
def test_include_yaml_error(): """Test include yaml error.""" with patch_yaml_files({"test.yaml": "value"}): conf = "key: !include test2.yaml" with io.StringIO(conf) as file: with pytest.raises(XKNXException): doc = yaml.load(file, Loader=SafeLineLoader) assert doc["key"] == "value"
def test_include_dir_list(mock_walk): """Test include dir list yaml.""" mock_walk.return_value = [["/test", [], ["two.yaml", "one.yaml"]]] with patch_yaml_files({"/test/one.yaml": "one", "/test/two.yaml": "two"}): conf = "key: !include_dir_list /test" with io.StringIO(conf) as file: doc = yaml.load(file, Loader=SafeLineLoader) assert doc["key"] == sorted(["one", "two"])