aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/test_xml.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-11-03 22:40:14 -0800
committerBryan Newbold <bnewbold@archive.org>2020-11-03 22:40:14 -0800
commit653fac9632c6ae9dd036ad844454cf419cd5320b (patch)
treec09d8a3d8a2524a991f082ab500bce53d1986caa /python/tests/test_xml.py
parent9beafd7c5fc98571ec26b49d223ce660378d7b9e (diff)
downloadsandcrawler-653fac9632c6ae9dd036ad844454cf419cd5320b.tar.gz
sandcrawler-653fac9632c6ae9dd036ad844454cf419cd5320b.zip
xml: re-encode XML docs into UTF-8 for persisting
Diffstat (limited to 'python/tests/test_xml.py')
-rw-r--r--python/tests/test_xml.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/python/tests/test_xml.py b/python/tests/test_xml.py
new file mode 100644
index 0000000..a996c56
--- /dev/null
+++ b/python/tests/test_xml.py
@@ -0,0 +1,18 @@
+
+import pytest
+
+from sandcrawler.xml import xml_reserialize
+
+
+def test_xml_reserialize() -> None:
+
+ with open('tests/files/scielo_article.jats.xml', 'rb') as f:
+ raw_xml = f.read()
+
+ assert b'encoding="ISO-8859-1"' in raw_xml
+ raw_xml.decode("ISO-8859-1")
+ with pytest.raises(UnicodeDecodeError):
+ raw_xml.decode("utf-8")
+
+ str_xml = xml_reserialize(raw_xml)
+ assert 'encoding="UTF-8"' in str_xml