Esempio n. 1
0
def test_read_json_or_yaml_file(tmp_path):
    """Read JSON or YAML file."""
    tempfile = tmp_path / "test.json"
    write_json_file(tempfile, {"test": "test"})
    read = read_json_or_yaml_file(tempfile)
    assert read["test"] == "test"

    tempfile = tmp_path / "test.yaml"
    write_yaml_file(tempfile, {"test": "test"})
    read = read_json_or_yaml_file(tempfile)
    assert read["test"] == "test"
Esempio n. 2
0
def test_get_file_from_type(tmp_path):
    """Test get file from type."""
    tempfile = tmp_path / "test1.yaml"
    write_yaml_file(tempfile, {"test": "test"})
    found = find_one_filetype(tmp_path, "test1", FILE_SUFFIX_CONFIGURATION)
    assert found.parts[-1] == "test1.yaml"

    tempfile = tmp_path / "test2.yml"
    write_yaml_file(tempfile, {"test": "test"})
    found = find_one_filetype(tmp_path, "test2", FILE_SUFFIX_CONFIGURATION)
    assert found.parts[-1] == "test2.yml"

    tempfile = tmp_path / "test3.json"
    write_yaml_file(tempfile, {"test": "test"})
    found = find_one_filetype(tmp_path, "test3", FILE_SUFFIX_CONFIGURATION)
    assert found.parts[-1] == "test3.json"

    tempfile = tmp_path / "test.config"
    write_yaml_file(tempfile, {"test": "test"})
    with pytest.raises(ConfigurationFileError):
        find_one_filetype(tmp_path, "test4", FILE_SUFFIX_CONFIGURATION)
Esempio n. 3
0
def test_reading_yaml(tmp_path):
    """Test reading YAML file."""
    tempfile = tmp_path / "test.yaml"
    write_yaml_file(tempfile, {"test": "test"})
    read = read_yaml_file(tempfile)
    assert read["test"] == "test"