Skip to content

Commit

Permalink
Update library_formulas test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
tswong committed May 17, 2011
1 parent 95930f6 commit df572a5
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 111 deletions.
Expand Up @@ -18,68 +18,72 @@
<up_axis>Y_UP</up_axis>
</asset>
<library_formulas>
<formula id="pitch" sid="formula1_sid" name="formula1_name">
<newparam sid="target1">
<formula id="pythagorean" name="pythagorean">
<newparam sid="hypotenuse">
<float>0</float>
</newparam>
<newparam sid="value">
<float>0</float>
<newparam sid="side1">
<int>0</int>
</newparam>
<newparam sid="pitch">
<float>0</float>
<newparam sid="side2">
<int>0</int>
</newparam>
<target>
<param>target1</param>
<param>hypotenuse</param>
</target>
<!-- target1 = (value/360) * pitch -->
<technique_common>
<math:math xmlns:math="http://www.w3.org/1998/Math/MathML">
<math:apply>
<math:times />
<math:apply>
<math:divide />
<math:csymbol encoding="COLLADA">value</math:csymbol>
<math:cn>360</math:cn>
<math:root/>
<math:degree><math:cn>2</math:cn></math:degree>
<math:apply>
<math:plus />
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side1</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side2</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
</math:apply>
<math:csymbol encoding="COLLADA">pitch</math:csymbol>
</math:apply>
</math:math>
</technique_common>
<technique profile="someProfile">
<param>some data</param>
<otherstuff type="someType">more data</otherstuff>
</technique>
</formula>
<formula id="pythagorean" name="pythagorean">
<newparam sid="hypotenuse">
<formula id="pitch" sid="formula1_sid" name="formula1_name">
<newparam sid="target1">
<float>0</float>
</newparam>
<newparam sid="side1">
<newparam sid="value">
<float>0</float>
</newparam>
<newparam sid="side2">
<newparam sid="pitch">
<float>0</float>
</newparam>
<target>
<param>hypotenuse</param>
<param>target1</param>
</target>
<!-- target1 = (value/360) * pitch -->
<technique_common>
<math:math xmlns:math="http://www.w3.org/1998/Math/MathML">
<math:apply>
<math:plus />
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side1</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
<math:times />
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side2</math:csymbol>
<math:cn>2</math:cn>
<math:divide />
<math:csymbol encoding="COLLADA">value</math:csymbol>
<math:cn>360</math:cn>
</math:apply>
<math:csymbol encoding="COLLADA">pitch</math:csymbol>
</math:apply>
</math:math>
</technique_common>
<technique profile="someProfile">
<param>some data</param>
<otherstuff type="someType">more data</otherstuff>
</technique>
</formula>
</library_formulas>
</COLLADA>
Expand Up @@ -18,71 +18,143 @@

# Please feed your node list here:

tagLstNewparam = ['library_formulas', 'formula', 'newparam']
newparamAtttName = 'sid'
tagLstTarget = ['library_formulas', 'formula', 'target', 'param']
tagLstRoot = ['library_formulas', 'formula']
rootAttrName = 'id'
tagLstNewparam = ['library_formulas', 'formula', 'newparam']
newparamAtttName = 'sid'
tagLstTarget = ['library_formulas', 'formula', 'target', 'param']
tagLstTechnique = ['library_formulas', 'formula', 'technique_common']
tagLstNewParamDataType = [['newparam', 'float'], ['newparam', 'int']]

# formula 1
newparamAttrVal1 = ['target1', 'value', 'pitch']
tagLstCsymbol1 = [['library_formulas', 'formula', 'technique_common', 'math:math', 'math:apply', 'math:apply', 'math:csymbol'],
['library_formulas', 'formula', 'technique_common', 'math:math', 'math:apply', 'math:csymbol']]
rootAttrVal1 = 'pythagorean'
newparamAttrVal1 = ['hypotenuse', 'side1', 'side2']
tagLstCsymbol1 = ['library_formulas', 'formula', 'technique_common', 'math', 'apply', 'apply', 'apply', 'csymbol']
newparamCount1 = [1, 2]

# formula 2
newparamAttrVal2 = ['hypotenuse', 'side1', 'side2']
tagLstCsymbol2 = ['library_formulas', 'formula', 'technique_common', 'math:math', 'math:apply', 'math:apply', 'math:csymbol']
rootAttrVal2 = 'pitch'
newparamAttrVal2 = ['target1', 'value', 'pitch']
tagLstCsymbol2 = [['library_formulas', 'formula', 'technique_common', 'math', 'apply', 'apply', 'csymbol'],
['library_formulas', 'formula', 'technique_common', 'math', 'apply', 'csymbol']]
newparamCount2 = [3, 0]

class SimpleJudgingObject:
def __init__(self, _tagLstNewparam, _newparamAtttName, _tagLstTarget, _newparamAttrVal1, _tagLstCsymbol1, _newparamAttrVal2, _tagLstCsymbol2):
self.tagLstNewparam = _tagLstNewparam
def __init__(self, _tagLstRoot, _rootAttrName, _tagLstNewparam, _newparamAtttName, _tagLstTarget, _tagLstTechnique, _tagLstNewParamDataType,
_rootAttrVal1, _newparamAttrVal1, _tagLstCsymbol1, _newparamCount1,
_rootAttrVal2, _newparamAttrVal2, _tagLstCsymbol2, _newparamCount2):

self.tagListRoot = _tagLstRoot
self.rootAttrName = _rootAttrName
self.tagListNewparam = _tagLstNewparam
self.newparamAtttName = _newparamAtttName
self.tagLstTarget = _tagLstTarget
self.tagListTarget = _tagLstTarget
self.tagListTechnique = _tagLstTechnique
self.tagListNewparamDataType = _tagLstNewParamDataType

self.rootAttrVal1 = _rootAttrVal1
self.newparamAttrVal1 = _newparamAttrVal1
self.tagLstCsymbol1 = _tagLstCsymbol1
self.tagListCsymbol1 = _tagLstCsymbol1
self.newparamCount1 = _newparamCount1

self.rootAttrVal2 = _rootAttrVal2
self.newparamAttrVal2 = _newparamAttrVal2
self.tagLstCsymbol2 = _tagLstCsymbol2
self.tagListCsymbol2 = _tagLstCsymbol2
self.newparamCount2 = _newparamCount2

self.status_baseline = False
self.status_superior = False
self.status_exemplary = False
self.__assistant = JudgeAssistant.JudgeAssistant()

# Add the name space to the tags
def AddNSToTagList(self, context):
nameSpace = self.__assistant.GetNameSpace(context, self.tagListTechnique)

def JudgeBaseline(self, context):
# No step should not crash
self.__assistant.CheckCrashes(context)

# Import/export/validate must exist and pass, while Render must only exist.
self.__assistant.CheckSteps(context, ["Import", "Export", "Validate"], ["Render"])

self.status_baseline = self.__assistant.GetResults()
return self.status_baseline
if (nameSpace != None):
for i in range(3, len(self.tagListCsymbol1)):
self.tagListCsymbol1[i] = nameSpace + ":" + self.tagListCsymbol1[i]

for i in range(3, len(self.tagListCsymbol2[0])):
self.tagListCsymbol2[0][i] = nameSpace + ":" + self.tagListCsymbol2[0][i]

for i in range(3, len(self.tagListCsymbol2[1])):
self.tagListCsymbol2[1][i] = nameSpace + ":" + self.tagListCsymbol2[1][i]

def CheckFormula1(self, context):

def CheckFormula1(self):
# check that the newparam attributes are preserved
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal1[0])
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal1[1])
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal1[2])
if ( (not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal1[0])) or
(not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal1[1])) or
(not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal1[2])) ):
return False

# check that the target data is preserved
self.__assistant.ElementDataCheck(context, self.tagLstTarget, self.newparamAttrVal1[0], "string")
if ( not self.__assistant.ElementDataCheck(context, self.tagListTarget, self.newparamAttrVal1[0], "string") ):
return False

# check that the newparam data types are preserved
if ( (self.__assistant.GetElementCount(self.tagListRoot, self.rootAttrName, self.rootAttrVal1, self.tagListNewparamDataType[0]) != self.newparamCount1[0]) ):
context.Log("FAILED: newparam <float> type not preserved")
return False
else:
context.Log("PASSED: newparam <float> type is preserved")

if ( (self.__assistant.GetElementCount(self.tagListRoot, self.rootAttrName, self.rootAttrVal1, self.tagListNewparamDataType[1]) != self.newparamCount1[1]) ):
context.Log("FAILED: newparam <int> type not preserved")
return False
else:
context.Log("PASSED: newparam <int> type is preserved")

# check that the csymbol data is preserved
self.__assistant.ElementDataCheck(context, self.tagLstCsymbol1[0], self.newparamAttrVal1[1], "string")
self.__assistant.ElementDataCheck(context, self.tagLstCsymbol1[1], self.newparamAttrVal1[2], "string")
if ( (not self.__assistant.ElementDataCheck(context, self.tagListCsymbol1, self.newparamAttrVal1[1], "string")) or
(not self.__assistant.ElementDataCheck(context, self.tagListCsymbol1, self.newparamAttrVal1[2], "string")) ):
return False

def CheckFormula2(self):
return True

def CheckFormula2(self, context):

# check that the newparam attributes are preserved
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal2[0])
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal2[1])
self.__assistant.AttributeCheck(context, self.tagLstNewparam, self.newparamAtttName, self.newparamAttrVal2[2])
if ( (not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal2[0])) or
(not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal2[1])) or
(not self.__assistant.AttributeCheck(context, self.tagListNewparam, self.newparamAtttName, self.newparamAttrVal2[2])) ):
return False

# check that the target data is preserved
self.__assistant.ElementDataCheck(context, self.tagLstTarget, self.newparamAttrVal2[0], "string")
if ( not self.__assistant.ElementDataCheck(context, self.tagListTarget, self.newparamAttrVal2[0], "string") ):
return False

# check that the newparam data types are preserved
if ( (self.__assistant.GetElementCount(self.tagListRoot, self.rootAttrName, self.rootAttrVal2, self.tagListNewparamDataType[0]) != self.newparamCount2[0]) ):
context.Log("FAILED: newparam <float> type not preserved")
return False
else:
context.Log("PASSED: newparam <float> type is preserved")

if ( (self.__assistant.GetElementCount(self.tagListRoot, self.rootAttrName, self.rootAttrVal2, self.tagListNewparamDataType[1]) != self.newparamCount2[1]) ):
context.Log("FAILED: newparam <int> type not preserved")
return False
else:
context.Log("PASSED: newparam <int> type is preserved")

# check that the csymbol data is preserved
self.__assistant.ElementDataCheck(context, self.tagLstCsymbol2, self.newparamAttrVal2[1], "string")
self.__assistant.ElementDataCheck(context, self.tagLstCsymbol2, self.newparamAttrVal2[2], "string")
if ( (not self.__assistant.ElementDataCheck(context, self.tagListCsymbol2[0], self.newparamAttrVal2[1], "string")) or
(not self.__assistant.ElementDataCheck(context, self.tagListCsymbol2[1], self.newparamAttrVal2[2], "string")) ):
return False

return True


def JudgeBaseline(self, context):
# No step should not crash
self.__assistant.CheckCrashes(context)

# Import/export/validate must exist and pass, while Render must only exist.
self.__assistant.CheckSteps(context, ["Import", "Export", "Validate"], [])

self.status_baseline = self.__assistant.GetResults()
return self.status_baseline

# To pass intermediate you need to pass basic, this object could also include additional
# tests that were specific to the intermediate badge.
Expand All @@ -98,18 +170,18 @@ def JudgeExemplary(self, context):
self.status_exemplary = self.status_superior
return self.status_exemplary

self.CheckFormula1()
self.AddNSToTagList(context)

if (self.__assistant.GetResults() == False):
if (self.CheckFormula1(context) == False):
self.status_exemplary = False
return self.status_exemplary

self.CheckFormula2()

self.status_exemplary = self.__assistant.DeferJudgement(context)
self.status_exemplary = self.CheckFormula2(context)
return self.status_exemplary

# This is where all the work occurs: "judgingObject" is an absolutely necessary token.
# The dynamic loader looks very specifically for a class instance named "judgingObject".
#
judgingObject = SimpleJudgingObject(tagLstNewparam, newparamAtttName, tagLstTarget, newparamAttrVal1, tagLstCsymbol1, newparamAttrVal2, tagLstCsymbol2);
judgingObject = SimpleJudgingObject(tagLstRoot, rootAttrName, tagLstNewparam, newparamAtttName, tagLstTarget, tagLstTechnique, tagLstNewParamDataType,
rootAttrVal1, newparamAttrVal1, tagLstCsymbol1, newparamCount1,
rootAttrVal2, newparamAttrVal2, tagLstCsymbol2, newparamCount2);
Expand Up @@ -23,28 +23,34 @@
<float>0</float>
</newparam>
<newparam sid="side1">
<float>0</float>
<int>0</int>
</newparam>
<newparam sid="side2">
<float>0</float>
<int>0</int>
</newparam>
<target>
<param>hypotenuse</param>
</target>
<technique_common>
<math:math xmlns:math="http://www.w3.org/1998/Math/MathML">
<math:apply>
<math:plus />
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side1</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side2</math:csymbol>
<math:cn>2</math:cn>

<math:root/>
<math:degree><math:cn>2</math:cn></math:degree>
<math:apply>
<math:plus />
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side1</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
<math:apply>
<math:power />
<math:csymbol encoding="COLLADA">side2</math:csymbol>
<math:cn>2</math:cn>
</math:apply>
</math:apply>

</math:apply>
</math:math>
</technique_common>
Expand Down

0 comments on commit df572a5

Please sign in to comment.