2018-05-07 01:45:56 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2020-04-22 01:22:10 +00:00
|
|
|
import os
|
|
|
|
import tempfile
|
2017-08-29 04:21:32 +00:00
|
|
|
import unittest
|
2018-05-07 01:45:56 +00:00
|
|
|
import util
|
2017-08-29 04:21:32 +00:00
|
|
|
|
|
|
|
|
2018-05-08 22:18:21 +00:00
|
|
|
class TestMisc(unittest.TestCase):
|
2018-05-07 03:21:59 +00:00
|
|
|
def runTest(self):
|
2018-05-08 22:18:21 +00:00
|
|
|
# version
|
2018-05-25 12:31:32 +00:00
|
|
|
self.assertEqual(util.invoke('version'), 6)
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2018-05-08 22:18:21 +00:00
|
|
|
# sync
|
2018-05-07 02:01:24 +00:00
|
|
|
util.invoke('sync')
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2018-05-08 22:18:21 +00:00
|
|
|
# multi
|
|
|
|
actions = [util.request('version'), util.request('version'), util.request('version')]
|
|
|
|
results = util.invoke('multi', actions=actions)
|
|
|
|
self.assertEqual(len(results), len(actions))
|
|
|
|
for result in results:
|
|
|
|
self.assertIsNone(result['error'])
|
2018-05-25 12:31:32 +00:00
|
|
|
self.assertEqual(result['result'], 6)
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2020-04-19 01:16:52 +00:00
|
|
|
# getNumCardsReviewedToday
|
|
|
|
result = util.invoke('getNumCardsReviewedToday')
|
|
|
|
self.assertIsInstance(result, int)
|
|
|
|
|
2020-04-22 01:22:10 +00:00
|
|
|
# exportPackage
|
|
|
|
fd, newname = tempfile.mkstemp(prefix='testexport', suffix='.apkg')
|
|
|
|
os.close(fd)
|
|
|
|
os.unlink(newname)
|
|
|
|
result = util.invoke('exportPackage', deck='Default', path=newname)
|
|
|
|
self.assertTrue(result)
|
|
|
|
self.assertTrue(os.path.exists(newname))
|
|
|
|
|
2018-05-07 01:45:56 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|