2018-05-09 03:38:28 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import util
|
|
|
|
|
|
|
|
|
|
|
|
class TestCards(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
util.invoke('createDeck', deck='test')
|
2021-01-19 05:03:27 +00:00
|
|
|
note = {
|
|
|
|
'deckName': 'test',
|
|
|
|
'modelName': 'Basic',
|
|
|
|
'fields': {'Front': 'front1', 'Back': 'back1'},
|
|
|
|
'tags': ['tag1'],
|
|
|
|
'options': {
|
|
|
|
'allowDuplicate': True
|
|
|
|
}
|
|
|
|
}
|
2018-05-09 03:38:28 +00:00
|
|
|
self.noteId = util.invoke('addNote', note=note)
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
util.invoke('deleteDecks', decks=['test'], cardsToo=True)
|
|
|
|
|
|
|
|
|
|
|
|
def runTest(self):
|
|
|
|
# findCards
|
|
|
|
cardIds = util.invoke('findCards', query='deck:test')
|
|
|
|
self.assertEqual(len(cardIds), 1)
|
|
|
|
|
2020-06-10 23:21:58 +00:00
|
|
|
# setEaseFactors
|
|
|
|
EASE_TO_TRY = 4200
|
|
|
|
easeFactors = [EASE_TO_TRY for card in cardIds]
|
|
|
|
couldGetEaseFactors = util.invoke('setEaseFactors', cards=cardIds, easeFactors=easeFactors)
|
|
|
|
self.assertEqual([True for card in cardIds], couldGetEaseFactors)
|
|
|
|
|
|
|
|
# getEaseFactors
|
|
|
|
easeFactorsFound = util.invoke('getEaseFactors', cards=cardIds)
|
|
|
|
self.assertEqual(easeFactors, easeFactorsFound)
|
|
|
|
|
2018-05-09 03:38:28 +00:00
|
|
|
# suspend
|
|
|
|
util.invoke('suspend', cards=cardIds)
|
|
|
|
|
|
|
|
# areSuspended (part 1)
|
|
|
|
suspendedStates = util.invoke('areSuspended', cards=cardIds)
|
|
|
|
self.assertEqual(len(cardIds), len(suspendedStates))
|
|
|
|
self.assertNotIn(False, suspendedStates)
|
|
|
|
|
|
|
|
# unsuspend
|
|
|
|
util.invoke('unsuspend', cards=cardIds)
|
|
|
|
|
|
|
|
# areSuspended (part 2)
|
|
|
|
suspendedStates = util.invoke('areSuspended', cards=cardIds)
|
|
|
|
self.assertEqual(len(cardIds), len(suspendedStates))
|
|
|
|
self.assertNotIn(True, suspendedStates)
|
|
|
|
|
|
|
|
# areDue
|
|
|
|
dueStates = util.invoke('areDue', cards=cardIds)
|
|
|
|
self.assertEqual(len(cardIds), len(dueStates))
|
|
|
|
self.assertNotIn(False, dueStates)
|
|
|
|
|
|
|
|
# getIntervals
|
|
|
|
util.invoke('getIntervals', cards=cardIds, complete=True)
|
|
|
|
util.invoke('getIntervals', cards=cardIds, complete=False)
|
|
|
|
|
|
|
|
# cardsToNotes
|
|
|
|
noteIds = util.invoke('cardsToNotes', cards=cardIds)
|
|
|
|
self.assertEqual(len(noteIds), len(cardIds))
|
|
|
|
self.assertIn(self.noteId, noteIds)
|
|
|
|
|
|
|
|
# cardsInfo
|
|
|
|
cardsInfo = util.invoke('cardsInfo', cards=cardIds)
|
|
|
|
self.assertEqual(len(cardsInfo), len(cardIds))
|
|
|
|
for i, cardInfo in enumerate(cardsInfo):
|
|
|
|
self.assertEqual(cardInfo['cardId'], cardIds[i])
|
|
|
|
|
2021-03-05 04:02:57 +00:00
|
|
|
# forgetCards
|
|
|
|
util.invoke('forgetCards', cards=cardIds)
|
|
|
|
|
|
|
|
# relearnCards
|
|
|
|
util.invoke('relearnCards', cards=cardIds)
|
2018-05-09 03:38:28 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|