wip
This commit is contained in:
parent
fb37ac9f8a
commit
d33b4e0dc7
@ -4,22 +4,22 @@ import unittest
|
|||||||
import util
|
import util
|
||||||
|
|
||||||
|
|
||||||
class TestVersion(unittest.TestCase):
|
class TestMisc(unittest.TestCase):
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
result = util.invokeNoError('version')
|
result = util.invoke('version')
|
||||||
self.assertEqual(result, 5)
|
self.assertEqual(result, 5)
|
||||||
|
|
||||||
|
|
||||||
def test_upgrade(self):
|
def test_upgrade(self):
|
||||||
util.invokeNoError('upgrade')
|
util.invoke('upgrade')
|
||||||
|
|
||||||
|
|
||||||
def test_sync(self):
|
def test_sync(self):
|
||||||
util.invokeNoError('sync')
|
util.invoke('sync')
|
||||||
|
|
||||||
|
|
||||||
def test_multi(self):
|
def test_multi(self):
|
||||||
result = util.invokeNoError(
|
result = util.invoke(
|
||||||
'multi', {
|
'multi', {
|
||||||
'actions': [
|
'actions': [
|
||||||
util.request('version'),
|
util.request('version'),
|
||||||
|
@ -9,11 +9,12 @@ def request(action, params={}, version=5):
|
|||||||
def invoke(action, params={}, version=5, url='http://localhost:8765'):
|
def invoke(action, params={}, version=5, url='http://localhost:8765'):
|
||||||
requestJson = json.dumps(request(action, params, version))
|
requestJson = json.dumps(request(action, params, version))
|
||||||
response = json.load(urllib2.urlopen(urllib2.Request(url, requestJson)))
|
response = json.load(urllib2.urlopen(urllib2.Request(url, requestJson)))
|
||||||
return response['result'], response['error']
|
if len(response) != 2:
|
||||||
|
raise Exception('response has an unexpected number of fields')
|
||||||
|
if 'error' not in response:
|
||||||
def invokeNoError(action, params={}, version=5, url='http://localhost:8765'):
|
raise Exception('response is missing required error field')
|
||||||
result, error = invoke(action, params, version, url)
|
if 'result' not in response:
|
||||||
if error is not None:
|
raise Exception('response is missing required result field')
|
||||||
raise Exception(error)
|
if response['error'] is not None:
|
||||||
return result
|
raise Exception(response['error'])
|
||||||
|
return response['result']
|
||||||
|
Loading…
Reference in New Issue
Block a user