コード例 #1
0
ファイル: yaml_loader_test.py プロジェクト: spacegaier/xknx
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"] == {}
コード例 #2
0
ファイル: yaml_loader_test.py プロジェクト: spacegaier/xknx
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"
コード例 #3
0
ファイル: yaml_loader_test.py プロジェクト: spacegaier/xknx
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"])