2018-05-07 05:13:21 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import util
|
|
|
|
|
|
|
|
|
2018-05-09 00:22:42 +00:00
|
|
|
class TestDecks(unittest.TestCase):
|
2018-05-07 05:13:21 +00:00
|
|
|
def runTest(self):
|
2018-05-09 00:22:42 +00:00
|
|
|
# deckNames (part 1)
|
|
|
|
deckNames = util.invoke('deckNames')
|
|
|
|
self.assertIn('Default', deckNames)
|
2018-05-07 05:13:21 +00:00
|
|
|
|
2018-05-09 00:22:42 +00:00
|
|
|
# deckNamesAndIds
|
2018-05-07 05:13:21 +00:00
|
|
|
result = util.invoke('deckNamesAndIds')
|
|
|
|
self.assertIn('Default', result)
|
|
|
|
self.assertEqual(result['Default'], 1)
|
|
|
|
|
2018-05-09 00:22:42 +00:00
|
|
|
# createDeck
|
2018-05-09 21:20:20 +00:00
|
|
|
util.invoke('createDeck', deck='test1')
|
2018-05-07 21:18:20 +00:00
|
|
|
|
2018-05-09 00:22:42 +00:00
|
|
|
# deckNames (part 2)
|
|
|
|
deckNames = util.invoke('deckNames')
|
2018-05-09 21:20:20 +00:00
|
|
|
self.assertIn('test1', deckNames)
|
2018-05-07 21:18:20 +00:00
|
|
|
|
2018-05-09 21:20:20 +00:00
|
|
|
# changeDeck
|
|
|
|
note = {'deckName': 'test1', 'modelName': 'Basic', 'fields': {'Front': 'front', 'Back': 'back'}, 'tags': ['tag']}
|
|
|
|
noteId = util.invoke('addNote', note=note)
|
|
|
|
cardIds = util.invoke('findCards', query='deck:test1')
|
|
|
|
util.invoke('changeDeck', cards=cardIds, deck='test2')
|
2018-05-09 00:22:42 +00:00
|
|
|
|
|
|
|
# deckNames (part 3)
|
|
|
|
deckNames = util.invoke('deckNames')
|
2018-05-09 21:20:20 +00:00
|
|
|
self.assertIn('test2', deckNames)
|
2018-05-07 21:18:20 +00:00
|
|
|
|
2018-05-09 21:20:20 +00:00
|
|
|
# deleteDecks
|
|
|
|
util.invoke('deleteDecks', decks=['test1', 'test2'], cardsToo=True)
|
2018-05-09 01:47:45 +00:00
|
|
|
|
|
|
|
# deckNames (part 4)
|
2018-05-09 21:20:20 +00:00
|
|
|
deckNames = util.invoke('deckNames')
|
|
|
|
self.assertNotIn('test1', deckNames)
|
|
|
|
self.assertNotIn('test2', deckNames)
|
2018-05-09 01:47:45 +00:00
|
|
|
|
2018-05-09 01:29:29 +00:00
|
|
|
# getDeckConfig
|
|
|
|
deckConfig = util.invoke('getDeckConfig', deck='Default')
|
|
|
|
self.assertEqual('Default', deckConfig['name'])
|
|
|
|
|
|
|
|
# saveDeckConfig
|
|
|
|
deckConfig = util.invoke('saveDeckConfig', config=deckConfig)
|
|
|
|
|
|
|
|
# setDeckConfigId
|
|
|
|
setDeckConfigId = util.invoke('setDeckConfigId', decks=['Default'], configId=1)
|
|
|
|
self.assertTrue(setDeckConfigId)
|
|
|
|
|
|
|
|
# cloneDeckConfigId (part 1)
|
|
|
|
deckConfigId = util.invoke('cloneDeckConfigId', cloneFrom=1, name='test')
|
|
|
|
self.assertTrue(deckConfigId)
|
|
|
|
|
|
|
|
# removeDeckConfigId (part 1)
|
|
|
|
removedDeckConfigId = util.invoke('removeDeckConfigId', configId=deckConfigId)
|
|
|
|
self.assertTrue(removedDeckConfigId)
|
|
|
|
|
|
|
|
# removeDeckConfigId (part 2)
|
|
|
|
removedDeckConfigId = util.invoke('removeDeckConfigId', configId=deckConfigId)
|
|
|
|
self.assertFalse(removedDeckConfigId)
|
|
|
|
|
|
|
|
# cloneDeckConfigId (part 2)
|
|
|
|
deckConfigId = util.invoke('cloneDeckConfigId', cloneFrom=deckConfigId, name='test')
|
|
|
|
self.assertFalse(deckConfigId)
|
2018-05-07 21:18:20 +00:00
|
|
|
|
2018-05-07 05:13:21 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|