updating note and deck tests

This commit is contained in:
Alex Yatskov 2018-05-08 18:47:45 -07:00
parent f79c98bb96
commit 95ab8164cd
3 changed files with 31 additions and 33 deletions

View File

@ -523,7 +523,6 @@ class AnkiConnect:
@api()
def changeDeck(self, cards, deck):
try:
self.startEditing()
did = self.collection().decks.id(deck)
@ -536,8 +535,7 @@ class AnkiConnect:
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.collection().db.execute('update cards set usn=?, mod=?, did=? where id in ' + scids, usn, mod, did)
self.stopEditing()

View File

@ -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'])

View File

@ -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)