def test_validating_against_dtd(self): xml = ET.XML(export.Export(self._raw_json).pipeline_pubmed()) dtd = ET.DTD(open('tests/dtd/scielo_pubmed/PubMed.dtd', 'r')) self.assertEqual(True, dtd.validate(xml))
def test_validating_against_schema(self): xml = export.Export(self._raw_json).pipeline_doaj() xsd = open('tests/xsd/scielo_doaj/doajArticles.xsd', 'rb').read() schema_root = etree.XML(xsd) schema = etree.XMLSchema(schema_root) xmlparser = etree.XMLParser(schema=schema) expected = etree.fromstring(xml, xmlparser).tag self.assertEqual('records', expected)
def test_validating_against_schema(self): xml = export.Export(self._raw_json).pipeline_crossref() xmlio = ET.parse(io.BytesIO(xml)) schema_root = ET.parse( open( os.path.dirname(__file__) + '/xsd/scielo_crossref/crossref4.4.0.xsd')) schema = ET.XMLSchema(schema_root) schema.assertValid(xmlio) self.assertTrue(schema.validate(xmlio)) self.assertEqual(None, schema.assertValid(xmlio))