Py tests

How to create Platform Python Test

 * Create file of Python test, for exaple TestLogin.py

from core.TestTemplate import TestTemplate import urllib2 import json class TestLogin(TestTemplate): # class body....
 * Implement interface TestTemplate, for example:

for example
 * Override execute method
 * use context to extract input information, for example
 * method should return boolean result and logs array

def execute(self, context): # extract data from context server = context['server']

# test body

# extract data from context return (result, log)


 * Complete test you can move to automation/py_tests/tests directory


 * To run tests locally use LocalRunner.py


 * To run tests server use WebRunner.py

Example of TestLogin:
from core.TestTemplate import TestTemplate import urllib2 import json

class TestLogin(TestTemplate): def execute(self, context): log = [] server = context['server']

# work with JSON jdata = json.dumps({'login':'Mark', 'password':'test'}) log.append(str(jdata)) resData = urllib2.urlopen(server + "/service/login", jdata) response = json.loads(resData.read) log.append(str(response)) result = response['errno'] == 0 return (result, log)

def isEnabled(self): return True

def getName(self): return 'TestLogin'

def getDescription(self): return "TestLogin: 1) send login request 2) parse response 3) analyze data"


 * Additionally: you need Python >= 2.7 and bottle (http://bottlepy.org/docs/dev/)