Skip to content

Commit

Permalink
test_node_names_software_datacite.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzouz-Thuderoz committed Feb 22, 2024
1 parent 9397706 commit f7484e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
7 changes: 1 addition & 6 deletions test/data/software/reference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
<identifier identifierType="swMATH">2</identifier>
<creators>
<creator>
<creatorName>Li, X.S.</creatorName>
</creator>
<creator>
<creatorName>Demmel, J.W.</creatorName>
</creator>
Li, X.S.,Demmel, J.W.
</creators>
<titles>
<title>SuperLU-DIST</title>
Expand Down
37 changes: 19 additions & 18 deletions test/test_node_names_software_datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
from xmldiff import main
from xmldiff.actions import MoveNode
from xml.dom.minidom import parse
from zbmath_rest2oai import getAsXml
dom = ET.parse('test/data/software/plain.xml')
xslt = ET.parse('xslt/software/xslt-software-transformation.xslt')
transform = ET.XSLT(xslt)
newdom = transform(dom)
real_string = str(newdom).replace('&','&amp;')
print(real_string)


expected_string1 = ET.tostring(ET.parse('test/data/software/reference.xml'))


class PlainXmlTest(unittest.TestCase):
def test_similarity(self):
dom = ET.parse('test/data/software/plain.xml')
xslt = ET.parse('xslt/software/xslt-software-transformation.xslt')
transform = ET.XSLT(xslt)
newdom = transform(dom)
real_string = ET.tostring(newdom, pretty_print=True).decode().replace('&', '&amp;')
print(real_string)

expected_string = ET.tostring(ET.parse('test/data/software/reference.xml'))

ref_location = os.path.join(os.path.dirname(__file__), 'data/software/reference.xml')
with open(ref_location) as f:
dom = parse(f)
expected_string = dom.toprettyxml()
print(type(expected_string))
diff = main.diff_texts(expected_string, real_string, {
'ratio_mode': 'fast',
'F': 1,
})
essentials = list(filter(lambda e: not isinstance(e, MoveNode), diff))
self.assertLessEqual(len(essentials), 0)
diff = main.diff_texts(expected_string, real_string, {
'ratio_mode': 'fast',
'F': 1,
})
essentials = list(filter(lambda e: not isinstance(e, MoveNode), diff))
self.assertLessEqual(len(essentials), 0)


if __name__ == '__main__':
Expand Down

0 comments on commit f7484e5

Please sign in to comment.