Ejemplo n.º 1
0
def test_augment4():
    """
        Check that we have a decent error if the remapping doesn't work for e.g. types reason.
    """
    # Simple case, one column extra
    dest_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_DST3)
    src_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_SRC3)
    with pytest.raises(AssertionError) as e_info:
        aug, remaps, errs = dest_mapping.augmented_with(src_mapping)
    assert e_info.value.args[
        0] == "Destination column 'cutted20' aka 'n56' and source column 'cutted20' aka 't14' have different types!"
Ejemplo n.º 2
0
def test_augment1():
    """
        Check that we can addition mappings.
    """
    # Simple case, one column extra
    dest_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP2)
    src_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP3)
    aug, transforms, errs = dest_mapping.augmented_with(src_mapping)
    # 5 in common, one in +
    assert len(aug) == 6
    assert not errs
    assert not transforms
Ejemplo n.º 3
0
def test_augment2():
    """
        Check that we can addition mappings.
    """
    # Simple case, one column extra
    dest_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_DST)
    src_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_SRC)
    aug, remap, errs = dest_mapping.augmented_with(src_mapping)
    # 5, all in common
    assert len(aug) == 5
    assert not errs
    assert remap == [('n01', 'n02'), ('n02', 'n05'), ('n03', 'n04'),
                     ('n04', 'n03'), ('n05', 'n01')]
Ejemplo n.º 4
0
def test_augment3():
    """
        Check that we can addition mappings.
    """
    # Simple case, one column extra
    dest_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_DST2)
    src_mapping = TableMapping(ObjectFields).load_from_equal_list(MAPP_SRC2)
    aug, remaps, errs = dest_mapping.augmented_with(src_mapping)
    # 7, wtf and nada are extra
    assert len(aug) == 7
    assert not errs
    assert remaps == [
        RemapOp(frm='n01', to='n02'),
        RemapOp(frm='n02', to='n05'),
        RemapOp(frm='n03', to='n04'),
        RemapOp(frm='n04', to='n06'),  # Newly added
        RemapOp(frm='n07', to='n03'),
        RemapOp(frm='n111', to='n07'),  # Newly added
        RemapOp(frm='n125', to='n01'),
        RemapOp(frm=None, to='n111'),
        RemapOp(frm=None, to='n125')
    ]