def test_edit_entry_undo(session): entry = DatabaseEntry() session.add(entry) session.commit() cmd = EditEntry(entry, id=42) cmd() session.commit() assert entry.id == 42 cmd.undo() session.commit() assert entry.id == 1
def test_edit_entry(session): entry = DatabaseEntry() session.add(entry) session.commit() assert entry.id == 1 EditEntry(entry, id=42)() assert entry.id == 42
def test_edit_entry_invalid(session): with pytest.raises(ValueError): EditEntry(DatabaseEntry())
def test_edit_entry_repr(): entry = DatabaseEntry(id=7) expected_repr_result = "<EditEntry(kwargs {'foo': 'bar'}, entry id 7)>" assert fnmatch.fnmatch(repr(EditEntry(entry, foo='bar')), expected_repr_result)