genCards() on model change

This commit is contained in:
Damien Elmes 2012-03-20 02:46:45 +09:00
parent 5c5341b5e5
commit 51b70a5787
2 changed files with 4 additions and 1 deletions

View file

@ -373,6 +373,7 @@ select id from notes where mid = ?)""" % " ".join(map),
self._changeNotes(nids, newModel, fmap)
if cmap:
self._changeCards(nids, newModel, cmap)
self.col.genCards(nids)
def _changeNotes(self, nids, newModel, map):
d = []

View file

@ -197,12 +197,14 @@ def test_modelChange():
deck.models.change(basic, [f.id], basic, None, map)
f.load()
c0.load()
# the card was deleted
try:
c1.load()
assert 0
except TypeError:
pass
assert len(f.cards()) == 1
# but we have two cards, as a new one was generated
assert len(f.cards()) == 2
# an unmapped field becomes blank
assert f['Front'] == 'b123'
assert f['Back'] == 'f'