Added the test portion, should tackle the midiless implementations
This commit is contained in:
parent
90e4c5a6d9
commit
b11eb913f1
|
|
@ -5,8 +5,9 @@ import re,configparser
|
|||
commandlist={1:"go",2:"stop",3:"resume",4:"timed_go",6:"set",7:"fire",10:"go_off"}
|
||||
# Doc says 11 is go_off, test says otherwise
|
||||
|
||||
def testfunction(val,**params):
|
||||
print(val,params)
|
||||
def testfunction(*params):
|
||||
print("testfunction used in GMA",params)
|
||||
return 1 # Not mandatory or even codex, just for testing purposes
|
||||
|
||||
#A MessageParse object MUST be included in the file, the rest is implementation Specific
|
||||
class MessageParse(BasicMessageParse):
|
||||
|
|
@ -61,7 +62,7 @@ class Actions(BasicActions):
|
|||
"""The list of action to perform when a message is read"""
|
||||
def __init__(self, interface):
|
||||
super(Actions, self).__init__(interface)
|
||||
self.addFunction("testfunction",testfunction)
|
||||
#print(interface)
|
||||
|
||||
# This funtion is MANDATORY, it makes the link between MessageParse and Action
|
||||
def __call__(self,match):
|
||||
|
|
@ -104,4 +105,4 @@ class MidiInterface(BasicMidiInterface):
|
|||
|
||||
def __init__(self,configfile):
|
||||
super(MidiInterface,self).__init__(configfile)
|
||||
self.functionlist["test"]=testfunction
|
||||
self.functionlist["testfunction"]=testfunction
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class BasicActions(object):
|
|||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return(self.sections)
|
||||
return(str(self.sections))
|
||||
|
||||
def prettyprint(self):
|
||||
for sect in self.sections:
|
||||
|
|
@ -330,13 +330,16 @@ class BasicMidiTrigger(object):
|
|||
# Lidl parsing incomming;
|
||||
t_parse=val.split("(")
|
||||
funct,params=t_parse[0],t_parse[1][:-1].split(',')
|
||||
print(funct,params,self.interface.functionlist)
|
||||
self.funct=self.interface.functionlist[funct](val,**params)
|
||||
self.params=params
|
||||
self.funct=self.parent.interface.functionlist[funct]
|
||||
except KeyError:
|
||||
print("[ERROR] Key {} not in list of functions".format(funct))
|
||||
# except:
|
||||
# print("[ERROR] Can't evaluate function {}".format(val))
|
||||
|
||||
def execspecialfn(self):
|
||||
return self.funct(self.params)
|
||||
|
||||
def addstate(self,valtrue,valfalse):
|
||||
"The message will now send two state values intead"
|
||||
self.toggle=True
|
||||
|
|
|
|||
23
test.py
23
test.py
|
|
@ -74,10 +74,16 @@ class mappingTest(minitest.simpleTestUnit):
|
|||
|
||||
self.currentTest("Loading Config")
|
||||
try:
|
||||
def testfunction(*params):
|
||||
print("| > testfunction used in test",params)
|
||||
return 1
|
||||
|
||||
class Emptyconfig():
|
||||
def __init__(self,configfile):
|
||||
self.config=configparser.ConfigParser()
|
||||
self.config.read(configfile)
|
||||
self.functionlist={"testfunction":testfunction}
|
||||
|
||||
def interfaceOut(self,nb):
|
||||
class EmptySender():
|
||||
def __init__(self):
|
||||
|
|
@ -86,8 +92,8 @@ class mappingTest(minitest.simpleTestUnit):
|
|||
def send(self,wev,**kwargs):
|
||||
pass
|
||||
return EmptySender()
|
||||
|
||||
self.act=GrandMA2.Actions(Emptyconfig("patch/test.ini"))
|
||||
self.e_config=Emptyconfig("patch/test.ini")
|
||||
self.act=GrandMA2.Actions(self.e_config)
|
||||
self.addSuccess()
|
||||
except IOError:
|
||||
self.addFailure("Can't load config file")
|
||||
|
|
@ -149,20 +155,18 @@ class mappingTest(minitest.simpleTestUnit):
|
|||
if st:
|
||||
self.addSuccess()
|
||||
|
||||
self.currentTest("Testing loading of functions")
|
||||
print(self.gm.functionlist)
|
||||
self.addSuccess()
|
||||
|
||||
self.currentTest("Testing custom function")
|
||||
try:
|
||||
st=True
|
||||
acts=self.act.findAction("custom",77,"2")
|
||||
# print(acts)
|
||||
for act in acts:
|
||||
if not act.function:
|
||||
# print(act,act.funct)
|
||||
if not act.funct or not act.execspecialfn():
|
||||
st=False
|
||||
self.addFailure("No custom function defined")
|
||||
break
|
||||
except:
|
||||
except KeyError:
|
||||
self.addFailure("Can't use custom function")
|
||||
st=False
|
||||
if st:
|
||||
|
|
@ -226,6 +230,9 @@ class LiveTest(minitest.simpleTestUnit):
|
|||
self.addSuccess()
|
||||
|
||||
self.currentTest("Loading Patch")
|
||||
|
||||
# print(GrandMA2.Actions)
|
||||
|
||||
Acts=GrandMA2.Actions(Inter)
|
||||
self.addSuccess()
|
||||
#Act.prettyprint()
|
||||
|
|
|
|||
Loading…
Reference in New Issue