Exemplo n.º 1
0
def test_reshuff():
    src_mapping = TableMapping(ObjectFields)
    src_mapping.load_from_equal_list(MAPP_SRC)
    dst_mapping = TableMapping(ObjectFields)
    dst_mapping.load_from_equal_list(MAPP_DST)
    remap = src_mapping.transforms_from(dst_mapping)
    assert remap == [('n01', 'n05'), ('n02', 'n01'), ('n03', 'n04'),
                     ('n04', 'n03'), ('n05', 'n02')]
Exemplo n.º 2
0
def test_mapping1():
    a_mapping = TableMapping(ObjectFields)
    a_mapping.load_from_equal_list(MAPP)
    assert len(a_mapping) == 70
    assert a_mapping.max_by_type['n'] == 69
    assert a_mapping.max_by_type['t'] == 1
    a_mapping.add_column_for_table('lol', 't')
    assert a_mapping.max_by_type['t'] == 2
    enc: str = a_mapping.as_equal_list()
    assert enc.split("=") == (MAPP + "\nt02=lol").split("=")
    assert a_mapping.find_tsv_cols(["cdexc", "no", "toto"]) == ["n69", "t01"]
Exemplo n.º 3
0
def test_overflow():
    """
        Check that if there are too many fields, it fails.
    """
    a_mapping = TableMapping(ObjectFields)
    a_mapping.load_from_equal_list(MAPP2)
    # OK we have 5 'n' fields, let's add 495 more
    for n in range(495):
        ok_added = a_mapping.add_column_for_table("fl%dd" % n, "n")
        assert ok_added
    ok_added = a_mapping.add_column_for_table("fl508d", "n")
    assert not ok_added
Exemplo n.º 4
0
def test_mapping2():
    a_mapping = TableMapping(ObjectFields)
    a_mapping.load_from_equal_list(MAPP2)
    assert len(a_mapping) == 5
    assert not a_mapping.is_empty()