cleanup
This commit is contained in:
parent
409245c41b
commit
e63f2116cd
@ -19,21 +19,21 @@ class TestDeckNamesAndIds(unittest.TestCase):
|
||||
|
||||
class TestCreateDeck(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
util.invoke('deleteDecks', {'decks': ['test']})
|
||||
util.invoke('deleteDecks', decks=['test'])
|
||||
|
||||
|
||||
def runTest(self):
|
||||
util.invoke('createDeck', {'deck': 'test'})
|
||||
util.invoke('createDeck', deck='test')
|
||||
self.assertIn('test', util.invoke('deckNames'))
|
||||
|
||||
|
||||
class TestDeleteDecks(unittest.TestCase):
|
||||
def setUp(self):
|
||||
util.invoke('createDeck', {'deck': 'test'})
|
||||
util.invoke('createDeck', deck='test')
|
||||
|
||||
|
||||
def runTest(self):
|
||||
util.invoke('deleteDecks', {'decks': ['test']})
|
||||
util.invoke('deleteDecks', decks=['test'])
|
||||
self.assertNotIn('test', util.invoke('deckNames'))
|
||||
|
||||
|
||||
|
@ -6,8 +6,7 @@ import util
|
||||
|
||||
class TestVersion(unittest.TestCase):
|
||||
def runTest(self):
|
||||
result = util.invoke('version')
|
||||
self.assertEqual(result, 5)
|
||||
self.assertEqual(util.invoke('version'), 5)
|
||||
|
||||
|
||||
class TestUpgrade(unittest.TestCase):
|
||||
@ -23,13 +22,12 @@ class TestSync(unittest.TestCase):
|
||||
class TestMulti(unittest.TestCase):
|
||||
def runTest(self):
|
||||
result = util.invoke(
|
||||
'multi', {
|
||||
'actions': [
|
||||
'multi',
|
||||
actions=[
|
||||
util.request('version'),
|
||||
util.request('version'),
|
||||
util.request('version')
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(len(result), 3)
|
||||
|
@ -1,14 +1,17 @@
|
||||
import json
|
||||
import urllib2
|
||||
|
||||
|
||||
def request(action, params={}, version=5):
|
||||
return {'action': action, 'params': params, 'version': version}
|
||||
API_VERSION = 5
|
||||
API_URL = 'http://localhost:8765'
|
||||
|
||||
|
||||
def invoke(action, params={}, version=5, url='http://localhost:8765'):
|
||||
requestJson = json.dumps(request(action, params, version))
|
||||
response = json.load(urllib2.urlopen(urllib2.Request(url, requestJson)))
|
||||
def request(action, **params):
|
||||
return {'action': action, 'params': params, 'version': API_VERSION}
|
||||
|
||||
|
||||
def invoke(action, **params):
|
||||
requestJson = json.dumps(request(action, **params))
|
||||
response = json.load(urllib2.urlopen(urllib2.Request(API_URL, requestJson)))
|
||||
if len(response) != 2:
|
||||
raise Exception('response has an unexpected number of fields')
|
||||
if 'error' not in response:
|
||||
|
Loading…
Reference in New Issue
Block a user