Skip to content

Commit

Permalink
add tests for html.escape
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperla authored and dwoz committed Aug 13, 2020
1 parent 6fa8f8e commit c5ea361
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/pytests/unit/returners/test_nagios_nrdp_return.py
Expand Up @@ -8,16 +8,33 @@ def test_prepare_xml():
service = "salt-minion"

opts = {
"service": service,
"hostname": hostname,
"service": service,
"checktype": "active",
}
prepared_xml = nagios_nrdp_return._prepare_xml(options=opts)
root = ET.fromstring(prepared_xml)

xml_ret = nagios_nrdp_return._prepare_xml(options=opts)
root = ET.fromstring(xml_ret)

checkresult = root.find("checkresult")
hostname_res = checkresult.find("hostname").text
servicename_res = checkresult.find("servicename").text

# Verify the regular XML format.
assert servicename_res == service
assert hostname_res == hostname


def test_escaped_xml():
opts = {
"hostname": "s&lt",
"output": 'output"',
"service": "salt-<minion>",
"checktype": "active",
}

xml_ret = nagios_nrdp_return._prepare_xml(options=opts)

assert "s&amp;lt" in xml_ret
assert "salt-&lt;minion&gt;" in xml_ret
assert "output&quot;" in xml_ret

0 comments on commit c5ea361

Please sign in to comment.