Fix whitespace issues
Change-Id: I7c96843996f4847f9e15022f1dc6cd85e8a092f7
diff --git a/TestON/core/dicttoobject.py b/TestON/core/dicttoobject.py
index 82e2828..13c2aa6 100644
--- a/TestON/core/dicttoobject.py
+++ b/TestON/core/dicttoobject.py
@@ -64,4 +64,4 @@
else:
self[k] = obj[k]
return self
-
+
diff --git a/TestON/core/iniparser.py b/TestON/core/iniparser.py
index c350a20..c416b4f 100644
--- a/TestON/core/iniparser.py
+++ b/TestON/core/iniparser.py
@@ -1,7 +1,7 @@
#/usr/bin/env python
'''
Created on 07-Jan-2013
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
TestON is free software: you can redistribute it and/or modify
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -28,12 +28,12 @@
Test-Topology parser
Module that parses the test from plain English and topology
from a specification file and prepares for execution.
- Test sequencer
+ Test sequencer
Module that executes the tests case by case,
step by step adding ability for step by step pause and debug later.
Object loader
- Module that connects and loads all the component connection objects
- for access in the test
+ Module that connects and loads all the component connection objects
+ for access in the test
'''
def __init__(self) :
self.default = ''
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
index fea797a..c33a9b0 100644
--- a/TestON/core/jsonparser.py
+++ b/TestON/core/jsonparser.py
@@ -1,7 +1,7 @@
#/usr/bin/env python
'''
Created on 07-Jan-2013
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
TestON is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -24,7 +24,7 @@
import json
class JsonParser:
'''
- Module that parses the response Json to Dictionary and Vice versa.
+ Module that parses the response Json to Dictionary and Vice versa.
'''
def __init__(self) :
self.default = ''
@@ -38,18 +38,18 @@
response_dict = json.loads(json_response)
except Exception:
main.log.error("Json Parser is unable to parse the string")
- return response_dict
-
+ return response_dict
+
'''
-
+
def dict_json(self,response_dict):
-
+
# This will parse the Python Dictionary and return content as Json string.
-
+
json_response = {}
try :
json_response = json.dumps(response_dict)
except Exception:
main.log.error("Json Parser is unable to parse the string")
- return json_response
+ return json_response
'''
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index e77d440..c65fa49 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -191,7 +191,7 @@
logfile.close()
print newmsg
- main.log.case = case
+ main.log.case = case
def step(msg):
'''
diff --git a/TestON/core/openspeak.py b/TestON/core/openspeak.py
index 59f2769..3794910 100644
--- a/TestON/core/openspeak.py
+++ b/TestON/core/openspeak.py
@@ -1,7 +1,7 @@
#/usr/bin/env python
'''
Created on 20-Dec-2012
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -28,34 +28,34 @@
def __init__(self):
self.default = ''
- self.flag = 0
+ self.flag = 0
self.CurrentStep = 0
self.grtrOrLssr = 0
def compiler(self,**compileParameters):
'''
- This method will parse the openspeak file and will write to a python module with the equivalent translations.
- It can accept OpenSpeak syntax in string or an OpenSpeak file as an input parameter.
+ This method will parse the openspeak file and will write to a python module with the equivalent translations.
+ It can accept OpenSpeak syntax in string or an OpenSpeak file as an input parameter.
Translated form can be written into python module if attribute "WRITETOFILE" is set to 1.
'''
-
+
args = self.parse_args(["OPENSPEAKFILE","TEXT","WRITETOFILE","FILEHANDLE"],**compileParameters)
resultString = ''
Test = "Mininet"
args["WRITETOFILE"] = args["WRITETOFILE"] if args["WRITETOFILE"] != None else 1
self.CurrentStep = 0
self.CurrentCase = ''
-
+
## here Open Speak file will be parsed by each line and translated.
if args["OPENSPEAKFILE"] !=None and args["TEXT"] ==None and args["FILEHANDLE"] == None:
self.openspeakfile = args["OPENSPEAKFILE"]
openSpeakFile = open(args["OPENSPEAKFILE"],"r").readlines()
-
- elif args["OPENSPEAKFILE"] ==None and args["TEXT"] and args["FILEHANDLE"] == None:
- openSpeakFile = args["TEXT"].split("\n")
+
+ elif args["OPENSPEAKFILE"] ==None and args["TEXT"] and args["FILEHANDLE"] == None:
+ openSpeakFile = args["TEXT"].split("\n")
elif args["FILEHANDLE"] and args["OPENSPEAKFILE"] ==None and args["TEXT"] ==None:
openSpeakFile = args["FILEHANDLE"].readlines()
-
+
index = 0
outputFile = []
testName = re.search("\/(.*)\.ospk$",self.openspeakfile,0)
@@ -64,32 +64,32 @@
testName = testName[len(testName)-1]
outputFile.append("\nclass " + testName + " :" + "\n")
outputFile.append("\n" + " " * 4 + "def __init__(self) :")
- outputFile.append("\n" + " " * 8 + "self.default = \'\'" + "\n")
-
+ outputFile.append("\n" + " " * 8 + "self.default = \'\'" + "\n")
+
while index < len(openSpeakFile):
ifelseMatch = re.match("\s+IF|\s+ELSE|\s+ELIF",openSpeakFile[index],flags=0)
line = openSpeakFile[index]
repeatMatch = re.match("\s*REPEAT", openSpeakFile[index], flags=0)
if ifelseMatch :
- result = self.verify_and_translate(line)
+ result = self.verify_and_translate(line)
initialSpaces = len(line) -len(line.lstrip())
- self.outLoopSpace = initialSpaces
+ self.outLoopSpace = initialSpaces
nextLine = openSpeakFile[index+1]
nextinitialSpaces = len(nextLine) -len(nextLine.lstrip())
-
-
+
+
while nextinitialSpaces > initialSpaces :
try :
elseMatch = re.match("\s*ELSE|\s*ELIF",nextLine,flags=0)
if elseMatch :
- self.flag = self.flag -1
- result = result + self.verify_and_translate(nextLine)
+ self.flag = self.flag -1
+ result = result + self.verify_and_translate(nextLine)
nextLine = openSpeakFile[index + 1]
nextinitialSpaces = len(nextLine) -len(nextLine.lstrip())
except IndexError:
- pass
+ pass
index = index + 1
- self.flag = 0
+ self.flag = 0
elif repeatMatch:
self.flag = 0
result = self.verify_and_translate(line)
@@ -97,15 +97,15 @@
endMatch = re.match("\s*END",openSpeakFile[index],flags=0)
while not endMatch :
try :
-
+
self.flag = self.flag + 1
result = result + self.verify_and_translate(openSpeakFile[index])
index = index + 1
-
+
except IndexError :
pass
-
-
+
+
else :
self.flag = 0
result = self.verify_and_translate(line)
@@ -119,64 +119,64 @@
testScript.write(lines)
testScript.close()
return resultString
-
+
def verify_and_translate(self,line):
'''
It will accept the each line and calls the suitable API to conver into pyton equivalent syntax .
- It will return the translated python syntax .
- '''
+ It will return the translated python syntax .
+ '''
lineSpace = re.match("^\s+",line,flags=0)
- initialSpaces = len(line) -len(line.lstrip())
- line = re.sub("^\s+","",line) if lineSpace else line
-
-
+ initialSpaces = len(line) -len(line.lstrip())
+ line = re.sub("^\s+","",line) if lineSpace else line
+
+
resultString = None
resultString = "\n" + " " * 4 if str(inspect.stack()[1][3]) == "compiler" else "\n"
- indent = " " *(4 + 4 * self.flag) if self.flag > 0 else " " * 4
+ indent = " " *(4 + 4 * self.flag) if self.flag > 0 else " " * 4
caseMatch = re.search("^CASE\s+(\d+)",line,flags=0)
nameMatch = re.match("^NAME\s+\"(.*)\"",line,flags=0)
commentMatch = re.match("^COMMENT\s+\"(.*)\"",line,flags=0)
stepMatch = re.match("^STEP\s+\"(.*)\"",line,flags=0)
connectMatch = re.match("^CONNECT\s+(\w+)\s+USING\s+(.*)",line,flags=0)
- disconnectMatch = re.match("^DISCONNECT\s+(.*)",line,flags=0)
+ disconnectMatch = re.match("^DISCONNECT\s+(.*)",line,flags=0)
ondoMatch = re.match("^ON\s+(.*)\s+DO\s+(.*)",line,flags=0)
-
+
storeMatch = re.match("^STORE\s+(.*)\s+IN\s+(.*)",line,flags=0)
- variableMatch = re.match("^(.*)\s+=\s+(.*)",line,flags=0)
+ variableMatch = re.match("^(.*)\s+=\s+(.*)",line,flags=0)
assertMatch = re.match("^ASSERT\s+(\w+)\s+(.*)\s+(.*)\s+ONPASS\s+(.*)\s+ONFAIL\s+(.*)",line,flags=0)
logMatch = re.match("^(ERROR|INFO|DEBUG|CRITICAL|REPORT|EXACT|WARN)\s+(.*)",line,flags=0)
ifloop = re.match("IF\s+(\w+)\s*(..|\w+)\s*(.*)",line,flags=0)
- elseloopMatch = re.match("ELSE\s*$",line,flags=0)
+ elseloopMatch = re.match("ELSE\s*$",line,flags=0)
elifloop = re.match("ELSE\sIF\s+(\w+)\s*(..|\w+)\s*(.*)",line,flags=0)
forloopMatch = re.match("\s*REPEAT\s+(/d+)\s+TIMES",line,flags=0)
experimentalMatch = re.match("EXPERIMENTAL\s+MODE\s+(\w+)",line,flags=0)
repeatMatch = re.match("\s*REPEAT\s+(\d+)\s+TIMES", line, flags=0)
-
+
response_pasrse = re.match("\s*PARSE\s+(\w+)\s+AS\s+(\w+)\s+INTO\s+(\w+)", line, flags=0)
-
+
if caseMatch :
self.CurrentStep = 0
self.CurrentCase = "CASE" + caseMatch.group(1)
resultString = resultString + self.translate_case_block(casenumber=caseMatch.group(1))
elif repeatMatch:
resultString = resultString + indent + self.translate_repeat(repeat=repeatMatch.group(1))
- elif nameMatch :
+ elif nameMatch :
resultString = resultString + indent + self.translate_testcase_name(testname=nameMatch.group(1))
- elif commentMatch :
+ elif commentMatch :
resultString = resultString + indent + self.translate_comment(comment=commentMatch.group(1))
elif stepMatch :
self.CurrentStep = self.CurrentStep + 1
resultString = resultString + indent + self.translate_step(step=stepMatch.group(1))
- elif connectMatch :
+ elif connectMatch :
resultString = resultString + indent + self.translate_connect(component=connectMatch.group(1),
arguments=connectMatch.group(2) )
elif disconnectMatch :
resultString = resultString + indent + self.translate_disconnect(component=disconnectMatch.group(1))
elif ondoMatch :
- resultString = resultString + indent + self.translate_onDOAs(component=ondoMatch.group(1),action=ondoMatch.group(2))
+ resultString = resultString + indent + self.translate_onDOAs(component=ondoMatch.group(1),action=ondoMatch.group(2))
elif storeMatch :
resultString = resultString + indent + self.translate_store(variable=storeMatch.group(2),
- value=storeMatch.group(1))
+ value=storeMatch.group(1))
elif variableMatch :
resultString = resultString + indent + self.translate_store(variable=variableMatch.group(1),
value=variableMatch.group(2))
@@ -185,48 +185,48 @@
operator=assertMatch.group(2),
rightvalue=assertMatch.group(3),
onpass=assertMatch.group(4),
- onfail=assertMatch.group(5))
+ onfail=assertMatch.group(5))
elif logMatch :
resultString = resultString + indent + self.translate_logs(loglevel=logMatch.group(1),
message=logMatch.group(2))
elif ifloop :
-
- self.initSpace = initialSpaces
+
+ self.initSpace = initialSpaces
operand = ifloop.group(1)
operator = ifloop.group(2)
- value = ifloop.group(3)
- resultString = resultString + indent + "if " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
- self.flag = self.flag + 1
+ value = ifloop.group(3)
+ resultString = resultString + indent + "if " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
+ self.flag = self.flag + 1
elif experimentalMatch :
resultString = resultString + indent + self.translate_experimental_mode(mode=experimentalMatch.group(1))
-
+
elif elseloopMatch :
if initialSpaces == self.initSpace or initialSpaces == self.outLoopSpace:
resultString = resultString + indent + "else :"
self.flag = self.flag + 1
else :
- indent = " " *(4 + 4 * (self.flag-1))
+ indent = " " *(4 + 4 * (self.flag-1))
resultString = resultString + indent + "else :"
self.flag = self.flag + 1
-
+
elif elifloop :
-
+
operand = elifloop.group(1)
operator = elifloop.group(2)
- value = elifloop.group(3)
+ value = elifloop.group(3)
if initialSpaces == self.initSpace or initialSpaces == self.outLoopSpace:
- resultString = resultString + indent + "elif " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
- self.flag = self.flag + 1
+ resultString = resultString + indent + "elif " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
+ self.flag = self.flag + 1
else :
- indent = " " *(4 + 4 * (self.flag-1))
- resultString = resultString + indent + "elif " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
+ indent = " " *(4 + 4 * (self.flag-1))
+ resultString = resultString + indent + "elif " + operand + self.translate_if_else_operator(conditionoperator=operator) + value + ":"
self.flag = self.flag + 1
elif response_pasrse :
output_string = response_pasrse.group(1)
req_format = response_pasrse.group(2)
store_in = response_pasrse.group(3)
- resultString = resultString + indent + store_in +'= main.response_parser('+output_string+",\""+req_format+"\")"
- self.flag = self.flag + 1
+ resultString = resultString + indent + store_in +'= main.response_parser('+output_string+",\""+req_format+"\")"
+ self.flag = self.flag + 1
return resultString
@@ -234,18 +234,18 @@
'''
this will transalte the repeat statement into a python equivalen while loop
'''
-
+
args = self.parse_args(["REPEAT"],**repeatStatement)
resultString = ''
-
+
resultString = "i = 0"
resultString = resultString + "\n" + " " * 8 +"while i<" + args["REPEAT"] + " :"
return resultString
-
+
def translate_if_else_operator(self,**loopBlock):
'''
This method will translate if-else loop block into its equivalent python code.
- Whole loop block will be passed into loopBlock List.
+ Whole loop block will be passed into loopBlock List.
It returns the transalted reuslt as a string.
'''
args = self.parse_args(["CONDITIONOPERATOR"],**loopBlock)
@@ -258,19 +258,19 @@
lesserEqualMatch = re.match("LESSER\s+THAN\s+OR\s+EQUALS$|<=\s*$",args["CONDITIONOPERATOR"],flags=0)
if equalsMatch :
resultString = resultString + " == "
- elif greaterMatch :
+ elif greaterMatch :
resultString = resultString + " > "
- elif lesserMatch :
- resultString = resultString + " < "
+ elif lesserMatch :
+ resultString = resultString + " < "
elif greaterEqualMatch:
resultString = resultString + " >= "
elif lesserEqualMatch :
resultString = resultString + " <= "
else :
- print "\n Error: Given Operator is not listed "
-
- return resultString
-
+ print "\n Error: Given Operator is not listed "
+
+ return resultString
+
def translate_experimental_mode(self,**modeType):
'''
This API will translate statment EXPERIMENTAL MODE ON/OFF into python equivalent.
@@ -284,33 +284,33 @@
if ONmatch :
resultString = "main.EXPERIMENTAL_MODE = main.TRUE"
elif OFFmatch :
- resultString = "main.EXPERIMENTAL_MODE = main.FALSE"
+ resultString = "main.EXPERIMENTAL_MODE = main.FALSE"
return resultString
def interpret(self,**interpetParameters):
'''
- This method will accept the OpenSpeak syntax into a string and will return
+ This method will accept the OpenSpeak syntax into a string and will return
a python equivalent translations statement
'''
-
+
args = self.parse_args(["TEXT","WRITETOFILE"],**interpetParameters)
resultString = ''
## here Open Speak syntax will be translated into python equivalent.
resultString = self.verify_and_translate(args["TEXT"])
lineSpace = re.match("^\s+",resultString,flags=0)
-
- resultString = re.sub("^\s+","",resultString) if lineSpace else resultString
+
+ resultString = re.sub("^\s+","",resultString) if lineSpace else resultString
return resultString
def translate_logs(self,**logStatement):
'''
- This will translate the OpenSpeak log message statements into python equivalent
+ This will translate the OpenSpeak log message statements into python equivalent
to resultString and returns resultString
'''
args = self.parse_args(["LOGLEVEL","MESSAGE"],**logStatement)
resultString = ''
- # convert the statement here
+ # convert the statement here
message = self.translate_log_message(message=args["MESSAGE"])
if args["LOGLEVEL"] == "INFO" :
resultString = resultString + "main.log.info(" + message + ")"
@@ -319,21 +319,21 @@
elif args["LOGLEVEL"] == "DEBUG" :
resultString = resultString + "main.log.debug(" + message + ")"
elif args["LOGLEVEL"] == "REPORT" :
- resultString = resultString + "main.log.report(" + message + ")"
+ resultString = resultString + "main.log.report(" + message + ")"
elif args["LOGLEVEL"] == "CRITICAL" :
resultString = resultString + "main.log.critical(" + message + ")"
elif args["LOGLEVEL"] == "WARN" :
resultString = resultString + "main.log.warn(" + args["MESSAGE"] + ")"
elif args["LOGLEVEL"] == "EXACT" :
- resultString = resultString + "main.log.exact(" + args["MESSAGE"] + ")"
+ resultString = resultString + "main.log.exact(" + args["MESSAGE"] + ")"
-
+
return resultString
def translate_log_message(self,**messageStatement) :
'''
This API will translate log messages if it is a string or Variable or combination
- of string and variable.
+ of string and variable.
It will return the analysed and translate message.
'''
args = self.parse_args(["MESSAGE"],**messageStatement)
@@ -351,28 +351,28 @@
quoteWord = stringWidVariableMatch.group(1)
variableRef = stringWidVariableMatch.group(2)
varMatch = re.search("PARAMS\[(.*)\]|STEP\[(.*)\]|TOPO\[(.*)\]|CASE\[(.*)\]",variableRef,flags=0)
- varRefMatch = re.search("\<(\w+)\>",variableRef,flags=0)
+ varRefMatch = re.search("\<(\w+)\>",variableRef,flags=0)
if varMatch :
resultString = resultString + "\"" + quoteWord + "\"" + " + " + self.translate_parameters(parameters=variableRef)
elif varRefMatch :
resultString = resultString + "\"" + quoteWord + "\"" + " + " + varRefMatch.group(1)
elif varRefMatch:
resultString = resultString + varRefMatch.group(1)
- else :
- print "\nError : Syntax error , Not defined way to give log message" + args["MESSAGE"]
+ else :
+ print "\nError : Syntax error , Not defined way to give log message" + args["MESSAGE"]
- return resultString
-
+ return resultString
+
def translate_assertion(self,**assertStatement):
'''
- This will translate the ASSERT <value1> <COMPARISON OPERATOR> <value2> into python
+ This will translate the ASSERT <value1> <COMPARISON OPERATOR> <value2> into python
equivalent to resultString and returns resultString
'''
args = self.parse_args(["LEFTVALUE","OPERATOR","RIGHTVALUE","ONPASS","ONFAIL"],**assertStatement)
resultString = ''
- # convert the statement here
+ # convert the statement here
notOperatorMatch = re.search("NOT\s+(.*)",args["OPERATOR"],flags=0)
- notOperatorSymbMatch = re.search("\!(.*)",args["OPERATOR"],flags=0)
+ notOperatorSymbMatch = re.search("\!(.*)",args["OPERATOR"],flags=0)
operator = ''
lastresultMatch = re.match("LAST_RESULT",args["RIGHTVALUE"],flags=0)
lastresponseMatch = re.match("LAST_RESPONSE",args["RIGHTVALUE"],flags=0)
@@ -382,11 +382,11 @@
operator = "main.last_response"
else :
operator = args["RIGHTVALUE"]
-
+
if args["OPERATOR"] == None or args["OPERATOR"] == "" :
print "\n Error : Operator has not been specified !!!"
elif notOperatorMatch or notOperatorSymbMatch:
-
+
operators = notOperatorMatch.group(1) if notOperatorMatch else notOperatorSymbMatch.group(1)
operators = self.translate_operator(operator=operators)
if self.grtrOrLssr == 0 :
@@ -400,7 +400,7 @@
",onpass=" + self.translate_assertMessage(message=args["ONPASS"]) +\
",onfail=" + self.translate_assertMessage(message=args["ONFAIL"]) + ")"
- else :
+ else :
operators = self.translate_operator(operator=args["OPERATOR"])
if self.grtrOrLssr == 0 :
resultString = resultString + "utilities.assert_" + operators + "(expect=" +\
@@ -414,8 +414,8 @@
",actual=" + self.translate_response_result(operator=args["RIGHTVALUE"]) +\
",onpass=" + self.translate_assertMessage(message=args["ONPASS"]) +\
",onfail=" + self.translate_assertMessage(message=args["ONFAIL"]) + ")"
-
-
+
+
return resultString
def translate_response_result(self,**operatorStatement):
@@ -426,7 +426,7 @@
args = self.parse_args(["OPERATOR"],**operatorStatement)
resultString = ''
lastResultMatch = re.match("LAST_RESULT",args["OPERATOR"],flags=0)
- lastResponseMatch = re.match("LAST_RESPONSE",args["OPERATOR"],flags=0)
+ lastResponseMatch = re.match("LAST_RESPONSE",args["OPERATOR"],flags=0)
if lastResultMatch :
resultString = resultString + "main.last_result"
elif lastResponseMatch:
@@ -435,7 +435,7 @@
resultString = resultString + args["OPERATOR"]
return resultString
-
+
def translate_assertMessage(self,**messageStatement) :
'''
This API will facilitate the translation of assert ONPASS or ONFAIL messages . The message can be
@@ -443,16 +443,16 @@
It will return the translated message
'''
args = self.parse_args(["MESSAGE"],**messageStatement)
-
+
connectMatch = re.search("CONNECT\s+(\w+)\s+USING\s+(.*)",args["MESSAGE"],flags=0)
- disconnectMatch = re.search("DISCONNECT\s+(.*)",args["MESSAGE"],flags=0)
+ disconnectMatch = re.search("DISCONNECT\s+(.*)",args["MESSAGE"],flags=0)
ondoMatch = re.search("ON\s+(.*)\s+DO\s+(.*)",args["MESSAGE"],flags=0)
paramsMatch = re.search("PARAMS\[(.*)\]|STEP\[(.*)\]|TOPO\[(.*)\]|CASE\[(.*)\]",args["MESSAGE"],flags=0)
stringMatch = re.search("\"(.*)\"|\'(.*)\'",args["MESSAGE"],flags=0)
variableMatch = re.search("\<(.*)\>",args["MESSAGE"],flags=0)
resultString = ''
- if connectMatch :
+ if connectMatch :
resultString = resultString + self.translate_connect(component=connectMatch.group(1),
arguments=connectMatch.group(2) )
elif disconnectMatch :
@@ -462,22 +462,22 @@
action=ondoMatch.group(2))
elif paramsMatch :
resultString = resultString + self.translate_parameters(parameters=args["MESSAGE"])
- elif stringMatch :
+ elif stringMatch :
resultString = resultString + "\"" + stringMatch.group(1) + "\""
elif variableMatch :
- resultString = resultString + variableMatch.group(1)
+ resultString = resultString + variableMatch.group(1)
elif args["MESSAGE"] == None :
- print "\n Error : Please pass a message or action for assertion "
-
- return resultString
-
+ print "\n Error : Please pass a message or action for assertion "
+
+ return resultString
+
def translate_operator(self,**operatorStatement) :
'''
It will translate the operator for assertion , by ensuring against given arguments.
It will return the translated assertion operator.
'''
args = self.parse_args(["OPERATOR"],**operatorStatement)
-
+
resultString = ''
equalsMatch = re.match("EQUALS$|==$",args["OPERATOR"],flags=0)
greaterMatch = re.match("GREATER\s+THAN$|>$",args["OPERATOR"],flags=0)
@@ -486,26 +486,26 @@
greaterEqualMatch = re.match("GREATER\s+THAN\s+OR\s+EQUALS$|>=$",args["OPERATOR"],flags=0)
lesserEqualMatch = re.match("LESSER\s+THAN\s+OR\s+EQUALS$|<=$",args["OPERATOR"],flags=0)
if equalsMatch :
-
+
resultString = resultString + "equals"
- elif greaterMatch :
+ elif greaterMatch :
self.grtrOrLssr = self.grtrOrLssr + 1
resultString = resultString + "greater"
- elif lesserMatch :
+ elif lesserMatch :
self.grtrOrLssr = self.grtrOrLssr + 1
resultString = resultString + "lesser"
elif stringMatch :
-
+
resultString = resultString + "matches"
elif greaterEqualMatch:
-
+
resultString = resultString + "greater_equals"
elif lesserEqualMatch :
-
+
resultString = resultString + "lesser_equals"
else :
- print "\n Error: Given Operator is not listed for assertion"
- return resultString
+ print "\n Error: Given Operator is not listed for assertion"
+ return resultString
def translate_store(self,**storeStatement):
'''
@@ -527,18 +527,18 @@
return resultString
-
+
def translate_disconnect(self,**disconnectStatement):
'''
- This will translate the DISCONNECT <component_name> into python
+ This will translate the DISCONNECT <component_name> into python
equivalent to resultString and returns resultString
'''
args = self.parse_args(["COMPONENT"],**disconnectStatement)
resultString = ''
# convert the statement here
- resultString = "main." + args["COMPONENT"] + ".disconnect()"
+ resultString = "main." + args["COMPONENT"] + ".disconnect()"
return resultString
-
+
def translate_onDOAs(self,**onDoStatement):
'''
This will translate the ON <component> DO <action> USING <arg1> AS <value1>,<arg2> AS <value2>
@@ -546,17 +546,17 @@
'''
args = self.parse_args(["COMPONENT","ACTION","ARGUMENTS"],**onDoStatement)
subString = ''
-
+
usingMatch = re.match("\s*(.*)\s+USING\s+(.*)",args["ACTION"],flags=0)
action = ''
if usingMatch :
action = usingMatch.group(1)
arguments = usingMatch.group(2)
subString = self.translate_usingas(arguments=arguments)
-
+
else :
andCheck = re.search ("(.*)\s+AND\s+(.*)",args["ACTION"],flags=0)
-
+
action = action + "()"
if andCheck:
action = andCheck.group(1) + "()"
@@ -564,19 +564,19 @@
else :
action = args["ACTION"]
action = action + "()"
- # convert the statement here
- resultString = "main." + args["COMPONENT"] + "." + action + subString
+ # convert the statement here
+ resultString = "main." + args["COMPONENT"] + "." + action + subString
return resultString
-
+
def handle_conjuction(self,**conjuctStatement):
'''
This will handle the conjuctions
'''
-
+
args = self.parse_args(["STATEMENT"],**conjuctStatement)
subSentence = ''
-
+
storeMatch = re.match("\s*STORE\s+(.*)\s+IN\s+(.*)",args["STATEMENT"],flags=0)
assertMatch = re.match("\s*ASSERT\s+(\w+)\s+(.*)\s+(.*)\s+ONPASS\s+(.*)\s+ONFAIL\s+(.*)",args["STATEMENT"],flags=0)
if storeMatch :
@@ -607,16 +607,16 @@
subSentence = self.handle_conjuction(statement=andCheck.group(2))
else :
line = args["ARGUMENTS"]
-
-
-
+
+
+
argsMatch = re.search("(.*),(.*)",line,flags=0)
if args["ARGUMENTS"] == None or args["ARGUMENTS"] == '' :
subString = ''
elif argsMatch :
-
+
argsList = line.split(",")
for index, arguments in enumerate(argsList):
argMatch = re.search("(.*)\s+AS\s+(.*)",arguments,flags=0)
@@ -639,7 +639,7 @@
if index == len(argsList) - 1 :
subString = subString + arguments
else :
- subString = subString + arguments + ","
+ subString = subString + arguments + ","
else :
argMatch = re.search("(.*)\s+AS\s+(.*)",args["ARGUMENTS"],flags=0)
if argMatch:
@@ -663,36 +663,36 @@
def translate_connect(self,**connectStatement):
'''
- This will translate the CONNECT <component_name> USING1 <arg1> AS <value1>, <arg2> AS <value2>
+ This will translate the CONNECT <component_name> USING1 <arg1> AS <value1>, <arg2> AS <value2>
into python equivalent to resultString and returns resultString
'''
args = self.parse_args(["COMPONENT","ARGUMENTS"],**connectStatement)
resultString = ''
subString = self.translate_usingas(arguments=args["ARGUMENTS"])
- # convert the statement here
- resultString = "main." + args["COMPONENT"] + ".connect(" + subString + ")"
+ # convert the statement here
+ resultString = "main." + args["COMPONENT"] + ".connect(" + subString + ")"
return resultString
def translate_parameters(self,**parameterStatement):
'''
- This will translate the OpenSpeak Case and Params parameters into python equivalent
+ This will translate the OpenSpeak Case and Params parameters into python equivalent
to resultString and returns resultString
'''
args = self.parse_args(["PARAMETERS"],**parameterStatement)
argument = args["PARAMETERS"]
resultString = ''
- ### match arguments
+ ### match arguments
paramsMatch = re.search("PARAMS((\[(.*)\])*)",argument,flags=0)
stepsMatch = re.search("STEP((\[(.*)\])*)",argument,flags=0)
casesMatch = re.search("CASE((\[(.*)\])*)",argument,flags=0)
topoMatch = re.search("TOPO((\[(.*)\])*)",argument,flags=0)
lastResultMatch = re.match("LAST_RESULT",argument,flags=0)
- lastResponseMatch = re.match("LAST_RESPONSE",argument,flags=0)
+ lastResponseMatch = re.match("LAST_RESPONSE",argument,flags=0)
# convert the statement here
if paramsMatch :
params = paramsMatch.group(1)
- resultString = resultString + "main.params" + self._argsCheck(checkvar=params)
+ resultString = resultString + "main.params" + self._argsCheck(checkvar=params)
elif stepsMatch :
resultString = resultString +"main.params[\'" + self.CurrentCase +\
"\'][\'STEP" + str(self.CurrentStep) + "\']" +\
@@ -705,19 +705,19 @@
self._argsCheck(checkvar=topoMatch.group(1))
elif lastResultMatch :
resultString = resultString + "main.last_result"
- elif lastResponseMatch :
- resultString = resultString + "main.last_response"
+ elif lastResponseMatch :
+ resultString = resultString + "main.last_response"
return resultString
def _argsCheck(self,**args):
''' This API will check if given argument is varibale reference or String and will translate accordingly.
It will return the tanslate form in resultString.
- '''
+ '''
args = self.parse_args(["CHECKVAR"],**args)
params = args["CHECKVAR"]
argsList = params.split("]")
resultString = ''
- del argsList[len(argsList) - 1]
+ del argsList[len(argsList) - 1]
for index,paramArgs in enumerate(argsList) :
argsWidVariable = re.search("(\"|\')\s*(\w+)\s*(\'|\")",paramArgs,flags=0)
if argsWidVariable :
@@ -728,71 +728,71 @@
def translate_step(self,**stepStatement):
'''
- This will translate the STEP "DO SOMETHING HERE" into python equivalent
+ This will translate the STEP "DO SOMETHING HERE" into python equivalent
to resultString and returns resultString
'''
args = self.parse_args(["STEP"],**stepStatement)
resultString = ''
resultString = "main.step(\"" + args["STEP"] + "\")"
- # convert the statement here
+ # convert the statement here
return resultString
-
+
def translate_comment(self,**commentStatement):
'''
- This will translate the COMMENT "DO SOMETHING HERE" into python equivalent
+ This will translate the COMMENT "DO SOMETHING HERE" into python equivalent
to resultString and returns resultString
'''
args = self.parse_args(["COMMENT"],**commentStatement)
resultString = ''
resultString = "#" + args["COMMENT"]
- # convert the statement here
- return resultString
-
+ # convert the statement here
+ return resultString
+
def translate_testcase_name(self,**nameStatement):
'''
- This method will convert NAME "<Testcase_name>" into python equivalent statement
- to resultString and returns resultString
- '''
+ This method will convert NAME "<Testcase_name>" into python equivalent statement
+ to resultString and returns resultString
+ '''
args = self.parse_args(["TESTNAME"],**nameStatement)
-
+
resultString = ''
- resultString = "main.case(\"" + args["TESTNAME"] + "\")"
- # convert the statement here
- return resultString
-
-
+ resultString = "main.case(\"" + args["TESTNAME"] + "\")"
+ # convert the statement here
+ return resultString
+
+
def translate_case_block(self,**caseBlock):
'''
- This method will translate the case block in test script .
+ This method will translate the case block in test script .
It returns the translated equivalent python code for test script
'''
args = self.parse_args(["CASENUMBER"],**caseBlock)
resultString = ""
resultString = "def CASE" + str(args["CASENUMBER"]) + "(self,main) :\n"
- # process the caseBlock List translate all statements underlying the given case
+ # process the caseBlock List translate all statements underlying the given case
return resultString
-
-
+
+
def translate_loop_block(self,*loopBlock):
'''
This method will translate for loop block into its equivalent python code.
- Whole loop block will be passed into loopBlock List.
+ Whole loop block will be passed into loopBlock List.
It returns the transalted reuslt as a string.
'''
resultString = ''
- # process the loopBlock List translate all statements underlying the given loop block
- return resultString
-
-
+ # process the loopBlock List translate all statements underlying the given loop block
+ return resultString
+
+
def translate_conjuction(self,conjuctionStatement):
'''
- This will translate the AND conjuction statements into python equivalent
+ This will translate the AND conjuction statements into python equivalent
to resultString and returns resultString
'''
resultString = ''
- # convert the statement here
+ # convert the statement here
return resultString
@@ -804,12 +804,12 @@
for key,value in kwargs.iteritems():
#currentKey = str.upper(key)
if isinstance(args,list) and str.upper(key) in args:
- for each in args:
+ for each in args:
if each==str.upper(key):
newArgs [str(each)] = value
elif each != str.upper(key) and (newArgs.has_key(str(each)) == False ):
newArgs[str(each)] = None
-
-
-
+
+
+
return newArgs
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index 1ba403d..02ade72 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
'''
Created on 23-Oct-2012
-
+
@authors: Anil Kumar (anilkumar.s@paxterrasolutions.com),
Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
@@ -18,9 +18,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
+
Utilities will take care about the basic functions like :
* Extended assertion,
* parse_args for key-value pair handling
@@ -43,7 +43,7 @@
* parse_args for key-value pair handling
* Parsing the params or topology file.
'''
-
+
def __init__(self):
self.wrapped = sys.modules[__name__]
@@ -57,7 +57,7 @@
return getattr(self.wrapped, name)
except AttributeError:
def assertHandling(**kwargs):
- nameVar = re.match("^assert",name,flags=0)
+ nameVar = re.match("^assert",name,flags=0)
matchVar = re.match("assert(_not_|_)(equals|matches|greater|lesser)",name,flags=0)
notVar = 0
operators = ""
@@ -193,16 +193,16 @@
for key,value in kwargs.iteritems():
#currentKey = str.upper(key)
if isinstance(args,list) and str.upper(key) in args:
- for each in args:
+ for each in args:
if each==str.upper(key):
newArgs [str(each)] = value
elif each != str.upper(key) and (newArgs.has_key(str(each)) == False ):
newArgs[str(each)] = None
-
-
-
+
+
+
return newArgs
-
+
def send_mail(self):
# Create a text/plain message
msg = email.mime.Multipart.MIMEMultipart()
@@ -213,16 +213,16 @@
sub = "Result summary of \""+main.TEST+"\": "+str(main.TOTAL_TC_SUCCESS)+"% Passed"
except KeyError,AttributeError:
sub = "Result summary of \""+main.TEST+"\": "+str(main.TOTAL_TC_SUCCESS)+"% Passed"
-
+
msg['Subject'] = sub
msg['From'] = 'paxweb@paxterrasolutions.com'
msg['To'] = main.mail
#msg['Cc'] = 'paxweb@paxterrasolutions.com'
-
+
# The main body is just another attachment
body = email.mime.Text.MIMEText(main.logHeader+"\n"+main.testResult)
msg.attach(body)
-
+
# Attachment
for filename in os.listdir(main.logdir):
filepath = main.logdir+"/"+filename
@@ -231,32 +231,32 @@
fp.close()
att.add_header('Content-Disposition','attachment',filename=filename)
msg.attach(att)
-
+
smtp = smtplib.SMTP('198.57.211.46')
smtp.starttls()
smtp.login('paxweb@paxterrasolutions.com','pax@peace')
smtp.sendmail(msg['From'],[msg['To']], msg.as_string())
smtp.quit()
- return main.TRUE
-
-
+ return main.TRUE
+
+
def parse(self,fileName):
'''
This will parse the params or topo or cfg file and return content in the file as Dictionary
'''
self.fileName = fileName
- matchFileName = re.match(r'(.*)\.(cfg|params|topo)',self.fileName,re.M|re.I)
+ matchFileName = re.match(r'(.*)\.(cfg|params|topo)',self.fileName,re.M|re.I)
if matchFileName:
try :
parsedInfo = ConfigObj(self.fileName)
return parsedInfo
except Exception:
- print "There is no such file to parse "+fileName
+ print "There is no such file to parse "+fileName
else:
- return 0
+ return 0
if __name__ != "__main__":
import sys
-
- sys.modules[__name__] = Utilities()
+
+ sys.modules[__name__] = Utilities()
diff --git a/TestON/core/xmldict.py b/TestON/core/xmldict.py
index f873014..2cc47da 100644
--- a/TestON/core/xmldict.py
+++ b/TestON/core/xmldict.py
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index a46750a..fea0ce9 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -1,7 +1,7 @@
#/usr/bin/env python
'''
Created on 07-Jan-2013
-
+
@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
TestON is free software: you can redistribute it and/or modify
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
'''
@@ -24,7 +24,7 @@
import re
class xmlparser :
-
+
def __init__(self) :
self.default = ''
@@ -40,7 +40,7 @@
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
except Exception:
- print "There is no such file to parse " + fileName
+ print "There is no such file to parse " + fileName
else :
print "file name is not correct"
@@ -48,7 +48,7 @@
'''
It will take the params file path and will return the params dictionary
'''
- paramsPath = re.sub("\.","/",paramsPath)
+ paramsPath = re.sub("\.","/",paramsPath)
paramsPath = re.sub("tests|examples","",paramsPath)
params = self.parse(main.tests_path+paramsPath+".params")
paramsAsString = str(params)
@@ -64,4 +64,4 @@
topology = self.parse(main.tests_path+topologyPath+".topo")
topoAsString = str(topology)
return eval(topoAsString)
-
+