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