0001-backoffice-report-expected-XML-node-in-invalid-XML-i.patch
tests/test_blockdef_import.py | ||
---|---|---|
1 |
import io |
|
2 | ||
3 |
import pytest |
|
4 | ||
5 |
from wcs.blocks import BlockDef, BlockdefImportError |
|
6 | ||
7 | ||
8 |
def test_import_root_node_error(): |
|
9 |
export = b'<wrong_root_node><name>Name</name></wrong_root_node>' |
|
10 |
with pytest.raises(BlockdefImportError) as excinfo: |
|
11 |
BlockDef.import_from_xml(io.BytesIO(export)) |
|
12 |
assert '<wrong_root_node>' in excinfo.value.msg |
tests/test_formdef_import.py | ||
---|---|---|
867 | 867 |
'Unknown field types: foobaz; ' |
868 | 868 |
'Unknown fields blocks: foobar, foobaz' |
869 | 869 |
) |
870 | ||
871 | ||
872 |
def test_import_formdef_root_node_error(): |
|
873 |
export = b'<wrong_root_node><name>Name</name></wrong_root_node>' |
|
874 |
with pytest.raises(FormdefImportError) as excinfo: |
|
875 |
FormDef.import_from_xml(io.BytesIO(export)) |
|
876 |
assert '<wrong_root_node>' in excinfo.value.msg |
tests/test_workflow_import.py | ||
---|---|---|
1135 | 1135 |
'Unknown mail templates: unknown-mt-1, unknown-mt-2; ' |
1136 | 1136 |
'Unknown roles: unknown-role1, unknown-role2' |
1137 | 1137 |
) |
1138 | ||
1139 | ||
1140 |
def test_import_root_node_error(): |
|
1141 |
export = b'<wrong_root_node><name>Name</name></wrong_root_node>' |
|
1142 |
with pytest.raises(WorkflowImportError) as excinfo: |
|
1143 |
Workflow.import_from_xml(io.BytesIO(export)) |
|
1144 |
assert '<wrong_root_node>' in excinfo.value.msg |
wcs/blocks.py | ||
---|---|---|
186 | 186 |
tree = tree.getroot() |
187 | 187 | |
188 | 188 |
if tree.tag != cls.xml_root_node: |
189 |
raise BlockdefImportError(_('Unexpected root node')) |
|
189 |
raise BlockdefImportError( |
|
190 |
_('Provided XML file is invalid, it starts with a <%(seen)s> tag instead of <%(expected)s>') |
|
191 |
% {'seen': tree.tag, 'expected': cls.xml_root_node} |
|
192 |
) |
|
190 | 193 | |
191 | 194 |
if include_id and tree.attrib.get('id'): |
192 | 195 |
blockdef.id = tree.attrib.get('id') |
wcs/formdef.py | ||
---|---|---|
1351 | 1351 |
tree = tree.getroot() |
1352 | 1352 | |
1353 | 1353 |
if tree.tag != cls.xml_root_node: |
1354 |
raise FormdefImportError(_('Unexpected root node')) |
|
1354 |
raise FormdefImportError( |
|
1355 |
_('Provided XML file is invalid, it starts with a <%(seen)s> tag instead of <%(expected)s>') |
|
1356 |
% {'seen': tree.tag, 'expected': cls.xml_root_node} |
|
1357 |
) |
|
1355 | 1358 | |
1356 | 1359 |
if include_id and tree.attrib.get('id'): |
1357 | 1360 |
formdef.id = tree.attrib.get('id') |
wcs/workflows.py | ||
---|---|---|
852 | 852 |
tree = tree.getroot() |
853 | 853 | |
854 | 854 |
if tree.tag != 'workflow': |
855 |
raise WorkflowImportError(_('Not a workflow')) |
|
855 |
raise WorkflowImportError( |
|
856 |
_('Provided XML file is invalid, it starts with a <%s> tag instead of <workflow>') % tree.tag |
|
857 |
) |
|
856 | 858 | |
857 | 859 |
if include_id and tree.attrib.get('id'): |
858 | 860 |
workflow.id = tree.attrib.get('id') |
859 |
- |