def test_update_replace(): t = Table() row1 = dict(vorname="rainer", nachname="greiff") row2 = dict(vorname="rainer", nachname="smith") row3 = dict(vorname="rainer", nachname="erhard") for row in [row1, row2, row3]: t.insert(row) t.update_replace(where={"nachname": "smith"}, nachname="greiff") assert len(t) == 2 assert len(list(t.find(nachname="greiff"))) == 1
def test_update_replace_no_replace(): t = Table() row1 = dict(vorname="rainer", nachname="greiff", address="123street") row2 = dict(vorname="rainer", nachname="smith", address="123street") row3 = dict(vorname="rainer", nachname="smith", address="456street") row4 = dict(vorname="luke", nachname="doe", address="23Street") for row in [row1, row2, row3, row4]: t.insert(row) t.update_replace(where={"nachname": "doe"}, nachname="greiff") assert len(t) == 4 assert len(list(t.find(nachname="greiff"))) == 2
def test_update_replace_multiple_replace(): t = Table() rows = [ dict(vorname="rainer", nachname="greiff", address="123street"), dict(vorname="rainer", nachname="greiff", address="123street"), dict(vorname="rainer", nachname="smith", address="123street"), dict(vorname="rainer", nachname="smith", address="123street"), dict(vorname="rainer", nachname="smith", address="123street"), dict(vorname="rainer", nachname="smith", address="456street"), dict(vorname="luke", nachname="doe", address="23Street"), ] for row in rows: t.insert(row) t.update_replace(where={"nachname": "smith"}, nachname="greiff") assert len(t) == 3 assert len(list(t.find(nachname="greiff"))) == 2