Example #1
0
def test_readcsv_fromfile_with_upd_props_mtable():
    filename = '__tbl__.csv'
    A1 = mg.read_csv(path_for_A)
    A1.to_csv(filename)
    A1.set_key('ID')
    A2 = mg.read_csv(filename, key='ID')
    assert_equal(A2.get_key(), 'ID')
    assert_equal(len(A1), len(A2))
Example #2
0
def test_readcsv_fromfile_with_upd_props_mtable():
    filename = '__tbl__.csv'
    A1 = mg.read_csv(path_for_A)
    A1.to_csv(filename)
    A1.set_key('ID')
    A2 = mg.read_csv(filename, key='ID')
    assert_equal(A2.get_key(), 'ID')
    assert_equal(len(A1), len(A2))
Example #3
0
def test_tocsv_mtable_wo_props_2():
    filename = '__tbl__.csv'
    A = mg.read_csv(path_for_A, key='ID')
    A.to_csv(filename, suppress_properties=True)
    A1 = mg.read_csv(filename, key='ID')
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(A1.get_key(), "ID")
    assert_equal(len(A1), len(A))
Example #4
0
def test_readcsv_fromfile_with_props_mtable():
    A1 = mg.read_csv(path_for_A, key='ID')
    filename = '__tbl__.csv'
    A1.to_csv(filename)
    A2 = mg.read_csv(filename)
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(A2.get_key(), 'ID')
    assert_equal(len(A1), len(A2))
Example #5
0
def test_tocsv_mtable_wi_props():
    filename = '__tbl__.csv'
    A = mg.read_csv(path_for_A, key='ID')
    A.to_csv(filename)
    A1 = mg.read_csv(filename)
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(A1.get_key(), A.get_key())
    assert_equal(len(A1), len(A))
Example #6
0
def test_readcsv_fromfile_with_props_mtable():
    A1 = mg.read_csv(path_for_A, key='ID')
    filename = '__tbl__.csv'
    A1.to_csv(filename)
    A2 = mg.read_csv(filename)
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(A2.get_key(), 'ID')
    assert_equal(len(A1), len(A2))
def test_bl_combiner_wi_no_tuples():
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'name', 'name')
    C = mg.combine_block_outputs_via_union([C1, C1, C1])
    s = ['_id', 'ltable.ID', 'rtable.ID']
    assert_equal(sorted(s) == sorted(C.columns), True)
    assert_equal(C.get_key(), '_id')
    assert_equal(C.get_property('foreign_key_ltable'), 'ltable.ID')
    assert_equal(C.get_property('foreign_key_rtable'), 'rtable.ID')
def test_bl_combiner_wi_no_tuples():
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'name', 'name')
    C = mg.combine_block_outputs_via_union([C1, C1, C1])
    s = ['_id', 'ltable.ID', 'rtable.ID']
    assert_equal(sorted(s) == sorted(C.columns), True)
    assert_equal(C.get_key(), '_id')
    assert_equal(C.get_property('foreign_key_ltable'), 'ltable.ID')
    assert_equal(C.get_property('foreign_key_rtable'), 'rtable.ID')
def test_bl_combiner_wi_no_fields():
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'zipcode', 'zipcode')
    C2 = ab.block_tables(A, B, 'hourly_wage', 'hourly_wage')
    C3 = ab.block_tables(A, B, 'birth_year', 'birth_year')
    C = mg.combine_block_outputs_via_union([C1, C2, C3])
    s = ['_id', 'ltable.ID', 'rtable.ID']
    assert_equal(sorted(s) == sorted(C.columns), True)
    assert_equal(C.get_key(), '_id')
    assert_equal(C.get_property('foreign_key_ltable'), 'ltable.ID')
    assert_equal(C.get_property('foreign_key_rtable'), 'rtable.ID')
Example #10
0
def test_bl_combiner_wi_no_fields():
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'zipcode', 'zipcode')
    C2 = ab.block_tables(A, B, 'hourly_wage', 'hourly_wage')
    C3 = ab.block_tables(A, B, 'birth_year', 'birth_year')
    C = mg.combine_block_outputs_via_union([C1, C2, C3])
    s = ['_id', 'ltable.ID', 'rtable.ID']
    assert_equal(sorted(s) == sorted(C.columns), True)
    assert_equal(C.get_key(), '_id')
    assert_equal(C.get_property('foreign_key_ltable'), 'ltable.ID')
    assert_equal(C.get_property('foreign_key_rtable'), 'rtable.ID')
Example #11
0
def test_tocsv_vtable_wi_props():
    filename = '__tbl__.csv'
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'zipcode', 'zipcode')
    C1.to_csv(filename, suppress_properties=False)
    C2 = mg.read_csv(filename, ltable=A, rtable=B)
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(C2.get_key(), C1.get_key())
    assert_equal(C2.get_property('foreign_key_ltable'), C1.get_property('foreign_key_ltable'))
    assert_equal(C2.get_property('foreign_key_rtable'), C1.get_property('foreign_key_rtable'))
Example #12
0
def test_readcsv_fromfile_with_props_vtable():
    filename = '__tbl__.csv'
    A = mg.read_csv(path_for_A, key='ID')
    B = mg.read_csv(path_for_B, key='ID')
    ab = mg.AttrEquivalenceBlocker()
    C1 = ab.block_tables(A, B, 'zipcode', 'zipcode')
    C1.to_csv(filename, suppress_properties=False)
    C2 = mg.read_csv(filename, ltable=A, rtable=B)
    try:
        os.remove(filename)
    except OSError:
        pass
    assert_equal(C2.get_key(), C1.get_key())
    assert_equal(C2.get_property('foreign_key_ltable'), C1.get_property('foreign_key_ltable'))
    assert_equal(C2.get_property('foreign_key_rtable'), C1.get_property('foreign_key_rtable'))
Example #13
0
def test_readcsv_valid_id():
    A = mg.read_csv(path_for_A, key='ID')
    assert_equal(A.get_key(), 'ID')
Example #14
0
def test_readcsv_key_not_present():
    mg.read_csv(path_for_A, key='ID1')
Example #15
0
def test_readcsv_no_id():
    A = mg.read_csv(path_for_A)
    assert_equal(A.get_key(), '_id')
Example #16
0
def test_readcsv_invalid_id():
    mg.read_csv(path_for_A, key='zipcode')
Example #17
0
def test_readcsv_no_id():
    A = mg.read_csv(path_for_A)
    assert_equal(A.get_key(), '_id')
Example #18
0
def test_readcsv_key_not_present():
    mg.read_csv(path_for_A, key='ID1')
Example #19
0
def test_readcsv_invalid_id():
    mg.read_csv(path_for_A, key='zipcode')
Example #20
0
def test_readcsv_valid_id():
    A = mg.read_csv(path_for_A, key='ID')
    assert_equal(A.get_key(), 'ID')