Fix tests for Python3
This commit is contained in:
parent
06c40ed85d
commit
24dd22145e
@ -2,10 +2,11 @@
|
||||
|
||||
import unittest
|
||||
import util
|
||||
import uuid
|
||||
|
||||
|
||||
MODEL_1_NAME = 'testModel'
|
||||
MODEL_2_NAME = 'testModel-second'
|
||||
MODEL_1_NAME = str(uuid.uuid4())
|
||||
MODEL_2_NAME = str(uuid.uuid4())
|
||||
|
||||
CSS = 'some random css'
|
||||
NEW_CSS = 'new random css'
|
||||
|
@ -1,17 +1,14 @@
|
||||
import json
|
||||
import urllib2
|
||||
|
||||
API_VERSION = 6
|
||||
API_URL = 'http://localhost:8765'
|
||||
import urllib.request
|
||||
|
||||
|
||||
def request(action, **params):
|
||||
return {'action': action, 'params': params, 'version': API_VERSION}
|
||||
|
||||
return {'action': action, 'params': params, 'version': 6}
|
||||
|
||||
def invoke(action, **params):
|
||||
requestJson = json.dumps(request(action, **params))
|
||||
response = json.load(urllib2.urlopen(urllib2.Request(API_URL, requestJson)))
|
||||
requestJson = json.dumps(request(action, **params)).encode('utf-8')
|
||||
response = json.load(urllib.request.urlopen(urllib.request.Request('http://localhost:8765', requestJson)))
|
||||
|
||||
if len(response) != 2:
|
||||
raise Exception('response has an unexpected number of fields')
|
||||
if 'error' not in response:
|
||||
@ -20,4 +17,5 @@ def invoke(action, **params):
|
||||
raise Exception('response is missing required result field')
|
||||
if response['error'] is not None:
|
||||
raise Exception(response['error'])
|
||||
|
||||
return response['result']
|
||||
|
Loading…
Reference in New Issue
Block a user