Esempio n. 1
0
def test_get_contents():
    s2 = get_test_hocon_str2()
    hs2 = HOCONString(s2)

    assert hs2.get_contents(with_include=True).strip() == s2
    assert (hs2.get_contents(with_include=False).strip() == s2.replace(
        INCLUDE_CROMWELL, '').strip())
Esempio n. 2
0
def test_get_contents():
    s2 = get_test_hocon_str2()
    hs2 = HOCONString(s2)

    c2 = hs2.get_contents(without_include=False)
    assert c2 == s2

    c2_wo_i = hs2.get_contents(without_include=True)
    assert c2_wo_i == s2.replace(INCLUDE_CROMWELL + '\n', '')
Esempio n. 3
0
def test_to_dict():
    hs = HOCONString(get_test_hocon_str())
    assert hs.to_dict(with_include=False) == get_test_dict(with_include=False)
    assert hs.to_dict(with_include=True) == get_test_dict(with_include=True)

    hs = HOCONString(get_test_hocon_str_multiple_includes())
    assert hs.to_dict(with_include=False) == get_test_multiple_includes(
        with_include=False)
    assert hs.to_dict(with_include=True) == get_test_multiple_includes(
        with_include=True)
Esempio n. 4
0
def test_merge():
    s1 = get_test_hocon_str()
    s2 = get_test_hocon_str2()

    d1 = get_test_dict()
    d2 = get_test_dict2()
    dm = deepcopy(d1)
    merge_dict(dm, d2)

    hs1 = HOCONString(s1)
    hs2 = HOCONString(s2)
    hsm = HOCONString.from_dict(dm, include=INCLUDE_CROMWELL)

    assert str(hsm) == hs1.merge(hs2)
    assert str(hsm) == hs1.merge(d2)
    assert str(hsm) == hs1.merge(s2)
Esempio n. 5
0
def test_merge():
    s1 = get_test_hocon_str()
    s2 = get_test_hocon_str2()
    s3 = get_test_hocon_str_multiple_includes()

    d1 = get_test_dict()
    d2 = get_test_dict2()
    d3 = get_test_multiple_includes(True)

    dm12 = deepcopy(d1)
    merge_dict(dm12, d2)
    dm32 = deepcopy(d3)
    merge_dict(dm32, d2)

    hs1 = HOCONString(s1)
    hs2 = HOCONString(s2)
    hs3 = HOCONString(s3)
    hsm12 = HOCONString.from_dict(dm12, include=INCLUDE_CROMWELL)
    hsm32 = HOCONString.from_dict(dm32)

    assert str(hsm12) == hs1.merge(hs2)
    assert str(hsm12) == hs1.merge(d2)
    assert str(hsm12) == hs1.merge(s2)

    assert str(hsm32) == hs3.merge(hs2)
    assert str(hsm32) == hs3.merge(d2)
    assert str(hsm32) == hs3.merge(s2)

    # merge with update
    # item 1 should be updated with merged
    hs1_original_str = str(hs1)
    assert str(hsm12) == hs1.merge(hs2, update=True)
    assert str(hs1) == str(hsm12)
    assert hs1_original_str != str(hs1)
Esempio n. 6
0
def test_from_dict():
    ref_d = get_test_dict()
    hs = HOCONString.from_dict(ref_d, include=INCLUDE_CROMWELL)
    print(str(hs))
    print(get_test_hocon_str())
    assert str(hs) == get_test_hocon_str()
Esempio n. 7
0
def test_to_dict():
    hs = HOCONString(get_test_hocon_str())
    assert hs.to_dict() == get_test_dict()
Esempio n. 8
0
def test_get_include():
    s2 = get_test_hocon_str2()
    hs2 = HOCONString(s2)

    assert hs2.get_include() == INCLUDE_CROMWELL