axel: accept XMLSchemaValidationError on encode or decode (#62631)
This commit is contained in:
parent
b1b80e5fa3
commit
4a2745b0df
|
@ -69,12 +69,14 @@ def test_bool_mapping(bool_type, value, expected, py_expected):
|
||||||
)
|
)
|
||||||
|
|
||||||
schema = CaluireAxelSchema(xsd, 'PORTAIL')
|
schema = CaluireAxelSchema(xsd, 'PORTAIL')
|
||||||
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
|
||||||
assert xml_data.find('BOOL').text == expected
|
|
||||||
|
|
||||||
if py_expected is None:
|
if py_expected is None:
|
||||||
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
||||||
|
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
||||||
|
assert xml_data.find('BOOL').text == expected
|
||||||
schema.decode(xml_data)
|
schema.decode(xml_data)
|
||||||
else:
|
else:
|
||||||
|
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
||||||
|
assert xml_data.find('BOOL').text == expected
|
||||||
json_data = schema.decode(xml_data)
|
json_data = schema.decode(xml_data)
|
||||||
assert json_data['BOOL'] is py_expected
|
assert json_data['BOOL'] is py_expected
|
||||||
|
|
|
@ -48,10 +48,9 @@ def test_date_mapping(date_type):
|
||||||
json_data = schema.decode(xml_data)
|
json_data = schema.decode(xml_data)
|
||||||
assert json_data['DATE'] == '2019-12-12'
|
assert json_data['DATE'] == '2019-12-12'
|
||||||
|
|
||||||
xml_data = schema.encode({'PORTAIL': {'DATE': 'foobar'}})
|
|
||||||
assert xml_data.find('DATE').text == 'foobar'
|
|
||||||
|
|
||||||
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
||||||
|
xml_data = schema.encode({'PORTAIL': {'DATE': 'foobar'}})
|
||||||
|
assert xml_data.find('DATE').text == 'foobar'
|
||||||
schema.decode(xml_data)
|
schema.decode(xml_data)
|
||||||
|
|
||||||
if date_type == 'DATEType':
|
if date_type == 'DATEType':
|
||||||
|
@ -107,12 +106,14 @@ def test_bool_mapping(bool_type, value, expected, py_expected):
|
||||||
)
|
)
|
||||||
|
|
||||||
schema = AxelSchema(xsd, 'PORTAIL')
|
schema = AxelSchema(xsd, 'PORTAIL')
|
||||||
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
|
||||||
assert xml_data.find('BOOL').text == expected
|
|
||||||
|
|
||||||
if py_expected is None:
|
if py_expected is None:
|
||||||
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
with pytest.raises(xmlschema.XMLSchemaValidationError):
|
||||||
|
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
||||||
|
assert xml_data.find('BOOL').text == expected
|
||||||
schema.decode(xml_data)
|
schema.decode(xml_data)
|
||||||
else:
|
else:
|
||||||
|
xml_data = schema.encode({'PORTAIL': {'BOOL': value}})
|
||||||
|
assert xml_data.find('BOOL').text == expected
|
||||||
json_data = schema.decode(xml_data)
|
json_data = schema.decode(xml_data)
|
||||||
assert json_data['BOOL'] is py_expected
|
assert json_data['BOOL'] is py_expected
|
||||||
|
|
Loading…
Reference in New Issue