# -*- coding: UTF-8 -*
"""Unit tests for XML exports
Usage: pytest tests/unit/test_export_xml.py
"""
# ScoDoc7 utilisait jaxml, obsolete et non portée en python3
# On teste ici les fonctions de remplacement, fournies par
# notre nouveau module sco_xml.py
import os
import re
import sys
import unittest
from app.scodoc import sco_xml
from app.scodoc.gen_tables import GenTable
# Legacy function
# import jaxml
# from app.scodoc import sco_utils as scu
# r = scu.simple_dictlist2xml([{"id": 1, "ues": [{"note": 10}, {}]}], tagname="infos")
def xml_normalize(x):
"supprime espaces inutiles"
x = re.sub(r"\s+", " ", str(x)).strip().replace("> <", "><")
def xmls_compare(x, y):
return xml_normalize(x) == xml_normalize(y)
def test_export_xml(test_client):
"""exports XML compatibles ScoDoc 7"""
# expected_result est le résultat de l'ancienne fonction ScoDoc7:
for data, expected_result in (
(
[{"id": 1, "ues": [{"note": 10}, {}, {"valeur": 25}]}, {"bis": 2}],
"""