示例#1
0
def test_dict_to_yaml_invalid_object():
    params = {Parameters(): Parameters()}
    with pytest.raises(RepresenterError):
        ConfigParser.dict_to_yaml(
            d=params,
            yaml_file=FILE_OUT,
        )
示例#2
0
def test_dict_to_yaml_wrong_type_yaml_file():
    params = Parameters().to_dict()
    with pytest.raises(TypeError):
        ConfigParser.dict_to_yaml(
            d=params,
            yaml_file=LIST,
        )
示例#3
0
def test_dict_to_yaml_file_unavailable():
    params = Parameters().to_dict()
    ret = ConfigParser.dict_to_yaml(
        d=params,
        yaml_file=FILE_UNAVAILABLE,
    )
    assert ret is None
示例#4
0
def test_dict_to_yaml_file_ok():
    params = Parameters().to_dict()
    ret = ConfigParser.dict_to_yaml(
        d=params,
        yaml_file=FILE_OUT,
    )
    assert ret is None
示例#5
0
def test_recursive_dict_update_correct_inputs():
    d = ConfigParser.recursive_dict_update(
        original=DICT_1,
        update=DICT_2,
    )
    assert d[KEY_1][KEY_2] == DICT_2[KEY_1][KEY_2]
    assert KEY_3 in d[KEY_1]
    assert KEY_4 in d
示例#6
0
def test_same_keys_wrong_types_ref():
    with pytest.raises(TypeError):
        ConfigParser.same_keys(
            query=QUERY,
            ref=INT,
        )
示例#7
0
def test_read_config_files_multi_config_partly_invalid():
    with pytest.raises(ParserError):
        ConfigParser.read_config_files(FILE_OK, FILE_NOT_YAML)
示例#8
0
def test_init_config_invalid():
    with pytest.raises(ParserError):
        ConfigParser(FILE_NOT_YAML)
示例#9
0
def test_init_single_config_log():
    res = ConfigParser(FILE_OK, log=True)
    assert type(res.values) is dict
示例#10
0
def test_yaml_to_dict_file_txt():
    with pytest.raises(TypeError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_TXT)
示例#11
0
def test_init_no_args():
    res = ConfigParser()
    assert res.values == {}
示例#12
0
def test_recursive_dict_update_arg1_int():
    with pytest.raises(TypeError):
        ConfigParser.recursive_dict_update(
            original=INT,
            update=DICT_1,
        )
示例#13
0
def test_yaml_to_dict_file_not_found():
    with pytest.raises(FileNotFoundError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_UNAVAILABLE)
示例#14
0
def test_same_keys_conflicting_inputs_two_way():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=REF,
        two_way=True,
    ) is False
示例#15
0
def test_same_keys_conflicting_inputs():
    assert ConfigParser.same_keys(
        query=QUERY_FALSE,
        ref=REF,
    ) is False
示例#16
0
def test_same_keys_correct_inputs_two_way():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=QUERY,
        two_way=True,
    ) is True
示例#17
0
def test_same_keys_correct_inputs():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=REF,
    ) is True
示例#18
0
def test_recursive_dict_update_arg2_str():
    with pytest.raises(TypeError):
        ConfigParser.recursive_dict_update(
            original=DICT_1,
            update=KEY_1,
        )
示例#19
0
def test_yaml_to_dict_file_ok():
    d = ConfigParser.yaml_to_dict(yaml_file=FILE_OK)
    assert type(d) is dict
    assert bool(d) is True
示例#20
0
def test_same_keys_wrong_types_query_int():
    assert ConfigParser.same_keys(
        query=INT,
        ref=REF,
    ) is False
示例#21
0
def test_yaml_to_dict_file_not_yaml():
    with pytest.raises(ParserError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_NOT_YAML)
示例#22
0
def test_same_keys_wrong_types_query_str():
    assert ConfigParser.same_keys(
        query=KEY_1,
        ref=REF,
    ) is False
示例#23
0
def test_yaml_to_dict_file_empty():
    assert ConfigParser.yaml_to_dict(yaml_file=FILE_EMPTY) == {}
示例#24
0
def test_same_keys_wrong_types_query_none():
    assert ConfigParser.same_keys(
        query=None,
        ref=REF,
    ) is False
示例#25
0
def test_init_config_unavailable():
    with pytest.raises(FileNotFoundError):
        ConfigParser(FILE_UNAVAILABLE)
示例#26
0
def test_same_keys_wrong_types_query_class():
    assert ConfigParser.same_keys(
        query=ConfigParser,
        ref=REF,
    ) is False
示例#27
0
def test_init_multi_config():
    res = ConfigParser(FILE_OK, FILE_OK)
    assert type(res.values) is dict
示例#28
0
def test_dict_to_yaml_wrong_type_d():
    with pytest.raises(TypeError):
        ConfigParser.dict_to_yaml(
            d=LIST,
            yaml_file=FILE_OUT,
        )
示例#29
0
def test_init_empty_config_log():
    res = ConfigParser(FILE_EMPTY, log=True)
    assert res.values == {}
示例#30
0
def test_read_config_files_single_config_invalid():
    with pytest.raises(ParserError):
        ConfigParser.read_config_files(FILE_NOT_YAML)