Ejemplo n.º 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,
        )
Ejemplo n.º 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,
        )
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 6
0
def test_same_keys_wrong_types_ref():
    with pytest.raises(TypeError):
        ConfigParser.same_keys(
            query=QUERY,
            ref=INT,
        )
Ejemplo n.º 7
0
def test_read_config_files_multi_config_partly_invalid():
    with pytest.raises(ParserError):
        ConfigParser.read_config_files(FILE_OK, FILE_NOT_YAML)
Ejemplo n.º 8
0
def test_init_config_invalid():
    with pytest.raises(ParserError):
        ConfigParser(FILE_NOT_YAML)
Ejemplo n.º 9
0
def test_init_single_config_log():
    res = ConfigParser(FILE_OK, log=True)
    assert type(res.values) is dict
Ejemplo n.º 10
0
def test_yaml_to_dict_file_txt():
    with pytest.raises(TypeError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_TXT)
Ejemplo n.º 11
0
def test_init_no_args():
    res = ConfigParser()
    assert res.values == {}
Ejemplo n.º 12
0
def test_recursive_dict_update_arg1_int():
    with pytest.raises(TypeError):
        ConfigParser.recursive_dict_update(
            original=INT,
            update=DICT_1,
        )
Ejemplo n.º 13
0
def test_yaml_to_dict_file_not_found():
    with pytest.raises(FileNotFoundError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_UNAVAILABLE)
Ejemplo n.º 14
0
def test_same_keys_conflicting_inputs_two_way():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=REF,
        two_way=True,
    ) is False
Ejemplo n.º 15
0
def test_same_keys_conflicting_inputs():
    assert ConfigParser.same_keys(
        query=QUERY_FALSE,
        ref=REF,
    ) is False
Ejemplo n.º 16
0
def test_same_keys_correct_inputs_two_way():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=QUERY,
        two_way=True,
    ) is True
Ejemplo n.º 17
0
def test_same_keys_correct_inputs():
    assert ConfigParser.same_keys(
        query=QUERY,
        ref=REF,
    ) is True
Ejemplo n.º 18
0
def test_recursive_dict_update_arg2_str():
    with pytest.raises(TypeError):
        ConfigParser.recursive_dict_update(
            original=DICT_1,
            update=KEY_1,
        )
Ejemplo n.º 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
Ejemplo n.º 20
0
def test_same_keys_wrong_types_query_int():
    assert ConfigParser.same_keys(
        query=INT,
        ref=REF,
    ) is False
Ejemplo n.º 21
0
def test_yaml_to_dict_file_not_yaml():
    with pytest.raises(ParserError):
        ConfigParser.yaml_to_dict(yaml_file=FILE_NOT_YAML)
Ejemplo n.º 22
0
def test_same_keys_wrong_types_query_str():
    assert ConfigParser.same_keys(
        query=KEY_1,
        ref=REF,
    ) is False
Ejemplo n.º 23
0
def test_yaml_to_dict_file_empty():
    assert ConfigParser.yaml_to_dict(yaml_file=FILE_EMPTY) == {}
Ejemplo n.º 24
0
def test_same_keys_wrong_types_query_none():
    assert ConfigParser.same_keys(
        query=None,
        ref=REF,
    ) is False
Ejemplo n.º 25
0
def test_init_config_unavailable():
    with pytest.raises(FileNotFoundError):
        ConfigParser(FILE_UNAVAILABLE)
Ejemplo n.º 26
0
def test_same_keys_wrong_types_query_class():
    assert ConfigParser.same_keys(
        query=ConfigParser,
        ref=REF,
    ) is False
Ejemplo n.º 27
0
def test_init_multi_config():
    res = ConfigParser(FILE_OK, FILE_OK)
    assert type(res.values) is dict
Ejemplo n.º 28
0
def test_dict_to_yaml_wrong_type_d():
    with pytest.raises(TypeError):
        ConfigParser.dict_to_yaml(
            d=LIST,
            yaml_file=FILE_OUT,
        )
Ejemplo n.º 29
0
def test_init_empty_config_log():
    res = ConfigParser(FILE_EMPTY, log=True)
    assert res.values == {}
Ejemplo n.º 30
0
def test_read_config_files_single_config_invalid():
    with pytest.raises(ParserError):
        ConfigParser.read_config_files(FILE_NOT_YAML)