updating note and deck tests
This commit is contained in:
parent
f79c98bb96
commit
95ab8164cd
@ -523,22 +523,20 @@ class AnkiConnect:
|
||||
|
||||
@api()
|
||||
def changeDeck(self, cards, deck):
|
||||
try:
|
||||
self.startEditing()
|
||||
self.startEditing()
|
||||
|
||||
did = self.collection().decks.id(deck)
|
||||
mod = anki.utils.intTime()
|
||||
usn = self.collection().usn()
|
||||
did = self.collection().decks.id(deck)
|
||||
mod = anki.utils.intTime()
|
||||
usn = self.collection().usn()
|
||||
|
||||
# normal cards
|
||||
scids = anki.utils.ids2str(cards)
|
||||
# remove any cards from filtered deck first
|
||||
self.collection().sched.remFromDyn(cards)
|
||||
# normal cards
|
||||
scids = anki.utils.ids2str(cards)
|
||||
# remove any cards from filtered deck first
|
||||
self.collection().sched.remFromDyn(cards)
|
||||
|
||||
# then move into new deck
|
||||
self.collection().db.execute('update cards set usn=?, mod=?, did=? where id in ?', scids, usn, mod, did)
|
||||
finally:
|
||||
self.stopEditing()
|
||||
# then move into new deck
|
||||
self.collection().db.execute('update cards set usn=?, mod=?, did=? where id in ' + scids, usn, mod, did)
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
@api()
|
||||
|
@ -23,12 +23,28 @@ class TestDecks(unittest.TestCase):
|
||||
self.assertIn('test', deckNames)
|
||||
|
||||
# deleteDecks
|
||||
util.invoke('deleteDecks', decks=['test'])
|
||||
util.invoke('deleteDecks', decks=['test'], cardsToo=True)
|
||||
|
||||
# deckNames (part 3)
|
||||
deckNames = util.invoke('deckNames')
|
||||
self.assertNotIn('test', deckNames)
|
||||
|
||||
# changeDeck
|
||||
# note = {'deckName': 'Default', 'modelName': 'Basic', 'fields': {'Front': 'front', 'Back': 'back'}, 'tags': ['tag']}
|
||||
# noteId = util.invoke('addNote', note=note)
|
||||
# util.invoke('changeDeck', cards=[noteId], deck='test')
|
||||
|
||||
# deckNames (part 4)
|
||||
# deckNames = util.invoke('deckNames')
|
||||
# self.assertIn('test', deckNames)
|
||||
|
||||
# deleteDecks (part 2)
|
||||
# util.invoke('deleteDecks', decks=['test'], cardsToo=True)
|
||||
|
||||
# deckNames (part 5)
|
||||
# deckNames = util.invoke('deckNames')
|
||||
# self.assertNotIn('test', deckNames)
|
||||
|
||||
# getDeckConfig
|
||||
deckConfig = util.invoke('getDeckConfig', deck='Default')
|
||||
self.assertEqual('Default', deckConfig['name'])
|
||||
|
@ -14,14 +14,8 @@ class TestNotes(unittest.TestCase):
|
||||
|
||||
|
||||
def runTest(self):
|
||||
note = {
|
||||
'deckName': 'test',
|
||||
'modelName': 'Basic',
|
||||
'fields': {'Front': 'front1', 'Back': 'back1'},
|
||||
'tags': ['tag1']
|
||||
}
|
||||
|
||||
# addNote
|
||||
note = {'deckName': 'test', 'modelName': 'Basic', 'fields': {'Front': 'front1', 'Back': 'back1'}, 'tags': ['tag1']}
|
||||
noteId = util.invoke('addNote', note=note)
|
||||
self.assertRaises(Exception, lambda: util.invoke('addNote', note=note))
|
||||
|
||||
@ -60,18 +54,8 @@ class TestNotes(unittest.TestCase):
|
||||
self.assertEqual(noteInfo['fields']['Back']['value'], 'back2')
|
||||
|
||||
notes = [
|
||||
{
|
||||
'deckName': 'test',
|
||||
'modelName': 'Basic',
|
||||
'fields': {'Front': 'front3', 'Back': 'back3'},
|
||||
'tags': ['tag']
|
||||
},
|
||||
{
|
||||
'deckName': 'test',
|
||||
'modelName': 'Basic',
|
||||
'fields': {'Front': 'front4', 'Back': 'back4'},
|
||||
'tags': ['tag']
|
||||
}
|
||||
{'deckName': 'test', 'modelName': 'Basic', 'fields': {'Front': 'front3', 'Back': 'back3'}, 'tags': ['tag']},
|
||||
{'deckName': 'test', 'modelName': 'Basic', 'fields': {'Front': 'front4', 'Back': 'back4'}, 'tags': ['tag']}
|
||||
]
|
||||
|
||||
# canAddNotes (part 1)
|
||||
|
Loading…
Reference in New Issue
Block a user