def test_set_key_valid(): df = mg.read_csv_metadata(path_for_A) mg.set_key(df, 'ID') assert_equal(mg.get_key(df), 'ID') mg.del_property(df, 'key') assert_equal(len(mg.get_all_properties(df)), 0)
def test_del_property_valid(): df = mg.read_csv_metadata(path_for_A) mg.set_key(df, 'ID') assert_equal(mg.get_key(df), 'ID') mg.del_property(df, 'key') assert_equal(mg.is_property_present_for_df(df, 'key'), False) mg.del_catalog()
def test_ab_block_candset_empty_output(self): C = self.ab.block_tables(self.A, self.B, l_block_attr_1, r_block_attr_1) D = self.ab.block_candset(C, l_block_attr_3, r_block_attr_3) assert_equal(len(D), 0) assert_equal(sorted(D.columns), sorted(C.columns)) assert_equal(mg.get_key(C), '_id') assert_equal(mg.get_property(D, 'fk_ltable'), mg.get_property(C, 'fk_ltable')) assert_equal(mg.get_property(D, 'fk_rtable'), mg.get_property(C, 'fk_rtable'))
def test_ab_block_tables_wi_no_output_tuples(self): C = self.ab.block_tables(self.A, self.B, l_block_attr_3, r_block_attr_3) assert_equal(len(C), 0) assert_equal(sorted(C.columns), sorted(['_id', 'ltable_' + l_key, 'rtable_' + r_key])) assert_equal(mg.get_key(C), '_id') assert_equal(mg.get_property(C, 'fk_ltable'), 'ltable_' + l_key) assert_equal(mg.get_property(C, 'fk_rtable'), 'rtable_' + r_key)
def test_ab_block_tables_wi_empty_r_output_attrs(self): C = self.ab.block_tables(self.A, self.B, l_block_attr_1, r_block_attr_1, l_output_attrs, []) s1 = ['_id', 'ltable_' + l_key, 'rtable_' + r_key] s1 += ['ltable_' + x for x in l_output_attrs if x != l_key] s1 = sorted(s1) assert_equal(s1, sorted(C.columns)) assert_equal(mg.get_key(C), '_id') assert_equal(mg.get_property(C, 'fk_ltable'), 'ltable_' + l_key) assert_equal(mg.get_property(C, 'fk_rtable'), 'rtable_' + r_key)
def test_ab_block_candset(self): C = self.ab.block_tables(self.A, self.B, l_block_attr_1, r_block_attr_1, l_output_attrs, r_output_attrs, l_output_prefix, r_output_prefix) D = self.ab.block_candset(C, l_block_attr_2, r_block_attr_2) assert_equal(sorted(C.columns), sorted(D.columns)) assert_equal(mg.get_key(D), '_id') assert_equal(mg.get_property(D, 'fk_ltable'), mg.get_property(C, 'fk_ltable')) assert_equal(mg.get_property(D, 'fk_rtable'), mg.get_property(C, 'fk_rtable')) k1 = pd.np.array(D[l_output_prefix + l_block_attr_2]) k2 = pd.np.array(D[r_output_prefix + r_block_attr_2]) assert_equal(all(k1 == k2), True)
def test_ab_block_tables(self): C = self.ab.block_tables(self.A, self.B, l_block_attr_1, r_block_attr_1, l_output_attrs, r_output_attrs, l_output_prefix, r_output_prefix) s1 = ['_id', l_output_prefix + l_key, r_output_prefix + r_key] s1 += [l_output_prefix + x for x in l_output_attrs if x != l_key] s1 += [r_output_prefix + x for x in r_output_attrs if x != r_key] s1 = sorted(s1) assert_equal(s1, sorted(C.columns)) assert_equal(mg.get_key(C), '_id') assert_equal(mg.get_property(C, 'fk_ltable'), l_output_prefix + l_key) assert_equal(mg.get_property(C, 'fk_rtable'), r_output_prefix + r_key) k1 = pd.np.array(C[l_output_prefix + l_block_attr_1]) k2 = pd.np.array(C[r_output_prefix + r_block_attr_1]) assert_equal(all(k1 == k2), True)