def testRunRulesMoleculeCH4MinOK(self): ver = Verification("test/moleculeCH4.IN.xml") #printRules(ver.rules) tree = ver.run(bad = True) xsd.assertValid(tree) #Need test RuleT03 self.assertEquals(etree.tostring(objectify.fromstring(open("test/moleculeCH4.OUT.MIN.xml").read()), pretty_print = True), etree.tostring(tree, pretty_print = True))
def testRunRulesTransition3MaxOK(self): rulesParser = RulesParser() rulesParser.useRules = set([Rule("atomRuleT01", None), Rule("atomRuleT02", None)]) ver = Verification("test/transition3OK.IN.xml", rulesParser.getRules()) tree = ver.run(report = True, bad = None) xsd.assertValid(tree) self.assertEquals(etree.tostring(objectify.fromstring(open("test/transition3OK.OUT.MAX.xml").read()), pretty_print = True), etree.tostring(tree, pretty_print = True))
def testDelRules(self): rulesParser = RulesParser() rulesParser.delRules = set([Rule("nltcsRuleT02", None)]) ver = Verification("test/moleculeH2O.IN.xml", rulesParser.getRules()) tree = ver.run() xsd.assertValid(tree) numberElements = tree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams":check.XSAMS_NS}) self.assertEquals(3, len(numberElements))
def testRunRulesMoleculeCO2MinOK(self): #rules = RulesParser().getRules(only={"ltcsRuleS04":{}}) rules = None ver = Verification("test/moleculeCO2.IN.xml", rules = rules) #printRules(ver.rules) tree = ver.run(report = False, bad = True) xsd.assertValid(tree) self.assertEquals(etree.tostring(objectify.fromstring(open("test/moleculeCO2.OUT.MIN.xml").read()), pretty_print = True), etree.tostring(tree, pretty_print = True))
def testUseOnlyRules(self): rulesParser = RulesParser() rulesParser.useRules = {Rule("nltcsRuleT02", None), Rule("nltcsRuleT03", None)} ver = Verification("test/moleculeH2O.IN.xml", rulesParser.getRules()) tree = ver.run() xsd.assertValid(tree) numberElements = tree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams":XSAMS_NS}) self.assertEquals(2, len(numberElements))
def testDelRules(self): rulesParser = RulesParser() rulesParser.delRules = set([Rule("nltcsRuleT02", None)]) ver = Verification("test/moleculeH2O.IN.xml", rulesParser.getRules()) tree = ver.run() xsd.assertValid(tree) numberElements = tree.xpath('//xsams:NumberOfVerificationByRule', namespaces={"xsams": XSAMS_NS}) self.assertEquals(3, len(numberElements))
def testRunRulesMoleculeN2OMinOK(self): ver = Verification("test/moleculeN2O.IN.xml") tree = ver.run(bad=True) xsd.assertValid(tree) self.assertEquals( etree.tostring(objectify.fromstring( open("test/moleculeN2O.OUT.MIN.xml").read()), pretty_print=True), etree.tostring(tree, pretty_print=True))
def testRunRulesTransition3MinOK(self): ver = Verification("test/transition3OK.IN.xml") tree = ver.run(report=False, bad=True) xsd.assertValid(tree) self.assertEquals( etree.tostring(objectify.fromstring( open("test/transition3OK.OUT.MIN.xml").read()), pretty_print=True), etree.tostring(tree, pretty_print=True))
def testAddRules(self): rulesParser = RulesParser() rulesParser.addRules = set([Rule("a", "nltcs:J < 9")]) ver = Verification("test/moleculeH2O.IN.xml", rulesParser.getRules()) tree = ver.run() xsd.assertValid(tree) numberElements = tree.xpath('//xsams:NumberOfVerificationByRule[@name = "aRuleS01"]', namespaces={"xsams":check.XSAMS_NS}) self.assertEquals(1, len(numberElements)) for numberElement in numberElements: self.assertEquals("6", numberElement.attrib["correct"]) self.assertEquals("3", numberElement.attrib["incorrect"])
def testRunRulesMoleculeCO2MinOK(self): #rules = RulesParser().getRules(only={"ltcsRuleS04":{}}) rules = None ver = Verification("test/moleculeCO2.IN.xml", rules=rules) #printRules(ver.rules) tree = ver.run(report=False, bad=True) xsd.assertValid(tree) self.assertEquals( etree.tostring(objectify.fromstring( open("test/moleculeCO2.OUT.MIN.xml").read()), pretty_print=True), etree.tostring(tree, pretty_print=True))
def testRunRulesTransition3MaxOK(self): rulesParser = RulesParser() rulesParser.useRules = set( [Rule("atomRuleT01", None), Rule("atomRuleT02", None)]) ver = Verification("test/transition3OK.IN.xml", rulesParser.getRules()) tree = ver.run(report=True, bad=None) xsd.assertValid(tree) self.assertEquals( etree.tostring(objectify.fromstring( open("test/transition3OK.OUT.MAX.xml").read()), pretty_print=True), etree.tostring(tree, pretty_print=True))
def testAddRules(self): rulesParser = RulesParser() rulesParser.addRules = set([Rule("a", "nltcs:J < 9")]) ver = Verification("test/moleculeH2O.IN.xml", rulesParser.getRules()) tree = ver.run() xsd.assertValid(tree) numberElements = tree.xpath( '//xsams:NumberOfVerificationByRule[@name = "aRuleS01"]', namespaces={"xsams": XSAMS_NS}) self.assertEquals(1, len(numberElements)) for numberElement in numberElements: self.assertEquals("5", numberElement.attrib["correct"]) self.assertEquals("3", numberElement.attrib["incorrect"])
def testRunRulesTransition1MinOK(self): rulesParser = RulesParser() ruleT02 = rulesParser.getRule("atomRuleT02").copy() ruleT02.name = "atomRuleT02F" ruleT02.forInChIList = [re.escape("InChI=1S/Fe/q+3/")] rulesParser.useRules.add(ruleT02) ver = Verification("test/transition1OK.IN.xml", rulesParser.getRules()) #printRules(ver.rules) tree = ver.run(report = False, bad = True) #with self.assertRaisesRegexp(etree.DocumentInvalid, "Element '{%s}atomRuleT02F': This element is not expected." % XSAMS_NS): xsd.assertValid(tree) #etree.parse("test/transition1OK.OUT.MIN.xml", etree.XMLParser(remove_blank_text=True)) #objectify.fromstring(open("test/transition1OK.OUT.MIN.xml").read()) self.assertEquals(etree.tostring(objectify.fromstring(open("test/transition1OK.OUT.MIN.xml").read()), pretty_print = True), etree.tostring(tree, pretty_print = True))
def testRunRulesTransition1MinOK(self): rulesParser = RulesParser() ruleT02 = rulesParser.getRule("atomRuleT02").copy() ruleT02.name = "atomRuleT02F" ruleT02.forInChIList = [re.escape("InChI=1S/Fe/q+3/")] rulesParser.useRules.add(ruleT02) ver = Verification("test/transition1OK.IN.xml", rulesParser.getRules()) #printRules(ver.rules) tree = ver.run(report=False, bad=True) #with self.assertRaisesRegexp(etree.DocumentInvalid, "Element '{%s}atomRuleT02F': This element is not expected." % XSAMS_NS): xsd.assertValid(tree) #etree.parse("test/transition1OK.OUT.MIN.xml", etree.XMLParser(remove_blank_text=True)) #objectify.fromstring(open("test/transition1OK.OUT.MIN.xml").read()) self.assertEquals( etree.tostring(objectify.fromstring( open("test/transition1OK.OUT.MIN.xml").read()), pretty_print=True), etree.tostring(tree, pretty_print=True))
def testRunRulesTransition3MinOK(self): ver = Verification("test/transition3OK.IN.xml") tree = ver.run(report = False, bad = True) xsd.assertValid(tree) self.assertEquals(etree.tostring(objectify.fromstring(open("test/transition3OK.OUT.MIN.xml").read()), pretty_print = True), etree.tostring(tree, pretty_print = True))
def testRunRulesMoleculeN2OMinOK(self): ver = Verification("test/moleculeN2O.IN.xml") tree = ver.run(bad = True) xsd.assertValid(tree) self.assertEquals(etree.tostring(objectify.fromstring(open("test/moleculeN2O.OUT.MIN.xml").read()), pretty_print = True), ver.getXML())