示例#1
0
    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"])
示例#2
0
	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))
示例#3
0
文件: tests.py 项目: xnx/VAMDC-VALD
	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))
示例#4
0
    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))
示例#5
0
文件: tests.py 项目: xnx/VAMDC-VALD
	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"])