def testAddRules(self): rulesParser = RulesParser() # 2.6 set([]) ; 2.7 {} rulesParser.addRules = set([ Rule(NODEID, "abs(nltcs:J + nltcs:Ka) <= 11"), Rule(NODEID, "abs(nltcs:Ka + nltcs:v1) <= pow(nltcs:v2, nltcs:Kc)") ]) queryfunc.rules = rulesParser.getRules() self.request.REQUEST = self.queryDict content = views.sync(self.request).content objTree = objectify.fromstring(content) verificationXSD.assertValid(objTree) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams": XSAMS_NS}) self.assertEquals(5, len(numberElements)) numberElements = objTree.xpath( '//xsams:NumberOfVerificationByRule[@name = "' + NODEID + 'RuleS01" or @name = "' + NODEID + 'RuleS02"]', namespaces={"xsams": XSAMS_NS}) self.assertEquals(2, len(numberElements)) for numberElement in numberElements: self.assertEquals("1", numberElement.attrib["correct"]) self.assertEquals("2", numberElement.attrib["incorrect"])
def testDelRules(self): rulesParser = RulesParser() rulesParser.delRules = set([Rule("nltcsRuleS01", None), Rule("nltcsRuleT02", None)]) queryfunc.rules = rulesParser.getRules() self.request.REQUEST = self.queryDict content = views.sync(self.request).content objTree = objectify.fromstring(content) verificationXSD.assertValid(objTree) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams":XSAMS_NS}) self.assertEquals(1, len(numberElements))
def testUseOnlyRules(self): rulesParser = RulesParser() rulesParser.useRules = {Rule("nltcsRuleT02", None), Rule(NODEID, "abs(nltcs:J + nltcs:Ka) <= 11")} queryfunc.rules = rulesParser.getRules() self.request.REQUEST = self.queryDict content = views.sync(self.request).content objTree = objectify.fromstring(content) verificationXSD.assertValid(objTree) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams":XSAMS_NS}) self.assertEquals(2, len(numberElements))
def testDelRules(self): rulesParser = RulesParser() rulesParser.delRules = set( [Rule("nltcsRuleS01", None), Rule("nltcsRuleT02", None)]) queryfunc.rules = rulesParser.getRules() self.request.REQUEST = self.queryDict content = views.sync(self.request).content objTree = objectify.fromstring(content) verificationXSD.assertValid(objTree) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams": XSAMS_NS}) self.assertEquals(1, len(numberElements))
def testAddRules(self): rulesParser = RulesParser() rulesParser.addRules = {Rule(NODEID, "abs(nltcs:J + nltcs:Ka) <= 11"), Rule(NODEID, "abs(nltcs:Ka + nltcs:v1) <= pow(nltcs:v2, nltcs:Kc)")} queryfunc.rules = rulesParser.getRules() self.request.REQUEST = self.queryDict content = views.sync(self.request).content objTree = objectify.fromstring(content) verificationXSD.assertValid(objTree) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams":XSAMS_NS}) self.assertEquals(5, len(numberElements)) numberElements = objTree.xpath('//xsams:NumberOfVerificationByRule[@name = "' + NODEID + 'RuleS01" or @name = "' + NODEID + 'RuleS02"]', namespaces={"xsams":XSAMS_NS}) self.assertEquals(2, len(numberElements)) for numberElement in numberElements: self.assertEquals("1", numberElement.attrib["correct"]) self.assertEquals("2", numberElement.attrib["incorrect"])