def test_delete_record(): for ext in ('.mst', '.xrf'): fname = join("..", "sample", 'one%s' % ext) if exists(fname): remove(fname) mf = MasterFile(join("..", "sample", "one.mst")) rec = MasterRecord() rec["300"] = "XXXX" rec.save(mf) print rec del mf mf = MasterFile(join("..", "sample", "one.mst")) l1 = len(mf) mf.delete(1) mf.commit() del mf mf = MasterFile(join("..", "sample", "one.mst")) l2 = len(mf) del mf print "l1=" + str(l1) print "l2=" + str(l2) assert l2 == l1 - 1, "wrong number of active records after deleting record"
def test_delete_record(): """Create 3 records and delete the one in the middle""" clean_start() size = 3 mf = MasterFile(testmst) for i in range(size): rec = MasterRecord() rec.update(test_data) rec.update({131: "flag %d" % i}) rec.save(mf) mf.delete(2)
def test_undelete(): """Create a record and undelete it""" clean_start() mf = MasterFile(testmst) r = MasterRecord() r.update(test_data) r.save(mf) mf.delete(1) mf.commit() r = mf[1] assert r.status == LOGICALLY_DELETED assert mf.xrf[1].status == 'logically deleted' assert len(mf) == 0 mf.undelete(1) r = mf[1] assert r.status == ACTIVE assert mf.xrf[1].status == 'active' assert len(mf) == 1