Skip to content
Snippets Groups Projects
Commit 3083b754 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

TST: refactored xml converter test

parent ec0d5c36
Branches
Tags
2 merge requests!181Release 0.9.0,!174XML Converter
...@@ -83,15 +83,8 @@ def converter_registry(): ...@@ -83,15 +83,8 @@ def converter_registry():
return converter_registry return converter_registry
def test_simple_xml(converter_registry): @pytest.fixture
xml_text = """ def basic_cfood():
<a href="test1" alt="no link">
test <img src="test2"/>
</a>
"""
tag = XMLTagElement("tag", lxml.etree.fromstring(xml_text))
xml_cfood = yaml.safe_load(""" xml_cfood = yaml.safe_load("""
type: XMLTag type: XMLTag
match_tag: a match_tag: a
...@@ -114,10 +107,33 @@ subtree: ...@@ -114,10 +107,33 @@ subtree:
match_name: alt match_name: alt
match_value: ^(?P<text>.*)$ match_value: ^(?P<text>.*)$
""") """)
return xml_cfood
@pytest.fixture
def basic_xmltag_converter(basic_cfood, converter_registry):
converter = XMLTagConverter(basic_cfood, "TestXMLTagConverter", converter_registry)
return converter
converter = XMLTagConverter(xml_cfood, "TestXMLTagConverter", converter_registry)
m = converter.match(tag) def test_simple_xml(basic_xmltag_converter):
"""
Test for basic xml conversion functionality.
"""
xml_text = """
<a href="test1" alt="no link">
test <img src="test2"/>
</a>
"""
tag = XMLTagElement("tag", lxml.etree.fromstring(xml_text))
m = basic_xmltag_converter.match(tag)
assert m is not None assert m is not None
assert m["ref"] == "href" assert m["ref"] == "href"
assert m["number"] == "1" assert m["number"] == "1"
def test_not_matching(basic_xmltag_converter):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment