diff --git a/tests/test_caluire_axel_schema.py b/tests/test_caluire_axel_schema.py index 2c392bfd..01d2d2e3 100644 --- a/tests/test_caluire_axel_schema.py +++ b/tests/test_caluire_axel_schema.py @@ -69,12 +69,14 @@ def test_bool_mapping(bool_type, value, expected, py_expected): ) schema = CaluireAxelSchema(xsd, 'PORTAIL') - xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) - assert xml_data.find('BOOL').text == expected if py_expected is None: with pytest.raises(xmlschema.XMLSchemaValidationError): + xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) + assert xml_data.find('BOOL').text == expected schema.decode(xml_data) else: + xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) + assert xml_data.find('BOOL').text == expected json_data = schema.decode(xml_data) assert json_data['BOOL'] is py_expected diff --git a/tests/test_toulouse_axel_schema.py b/tests/test_toulouse_axel_schema.py index 67c8e1ae..d955559f 100644 --- a/tests/test_toulouse_axel_schema.py +++ b/tests/test_toulouse_axel_schema.py @@ -48,10 +48,9 @@ def test_date_mapping(date_type): json_data = schema.decode(xml_data) 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): + xml_data = schema.encode({'PORTAIL': {'DATE': 'foobar'}}) + assert xml_data.find('DATE').text == 'foobar' schema.decode(xml_data) if date_type == 'DATEType': @@ -107,12 +106,14 @@ def test_bool_mapping(bool_type, value, expected, py_expected): ) schema = AxelSchema(xsd, 'PORTAIL') - xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) - assert xml_data.find('BOOL').text == expected if py_expected is None: with pytest.raises(xmlschema.XMLSchemaValidationError): + xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) + assert xml_data.find('BOOL').text == expected schema.decode(xml_data) else: + xml_data = schema.encode({'PORTAIL': {'BOOL': value}}) + assert xml_data.find('BOOL').text == expected json_data = schema.decode(xml_data) assert json_data['BOOL'] is py_expected