working on deck tests

This commit is contained in:
Alex Yatskov 2018-05-06 22:13:21 -07:00
parent acad72732f
commit 9e24d82a39
2 changed files with 30 additions and 1 deletions

View File

@ -360,6 +360,14 @@ class AnkiConnect:
return collection return collection
def decks(self):
decks = self.collection().decks
if decks is None:
raise Exception('decks are not available')
else:
return decks
def scheduler(self): def scheduler(self):
scheduler = self.collection().sched scheduler = self.collection().sched
if scheduler is None: if scheduler is None:
@ -472,7 +480,7 @@ class AnkiConnect:
@api() @api()
def deckNames(self): def deckNames(self):
return self.collection().decks.allNames() return self.decks().allnames()
@api() @api()

21
tests/test_decks.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
import unittest
import util
class TestDeckNames(unittest.TestCase):
def runTest(self):
result = util.invoke('deckNames')
self.assertIn('Default', result)
class TestDeckNamesAndIds(unittest.TestCase):
def runTest(self):
result = util.invoke('deckNamesAndIds')
self.assertIn('Default', result)
self.assertEqual(result['Default'], 1)
if __name__ == '__main__':
unittest.main()