Strip invalid XML characters from response
This commit is contained in:
parent
2469a6ea47
commit
9676714dcf
2 changed files with 59 additions and 4 deletions
|
@ -27,3 +27,42 @@ def test_get_cache_key(artist):
|
|||
def test_cast_and_hash(obj):
|
||||
assert type(str(obj)) is str
|
||||
assert isinstance(hash(obj), int)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_input, expected",
|
||||
[
|
||||
(
|
||||
# Plain text
|
||||
'<album mbid="">test album name</album>',
|
||||
'<album mbid="">test album name</album>',
|
||||
),
|
||||
(
|
||||
# Contains Unicode ENQ Enquiry control character
|
||||
'<album mbid="">test album \u0005name</album>',
|
||||
'<album mbid="">test album name</album>',
|
||||
),
|
||||
],
|
||||
)
|
||||
def test__remove_invalid_xml_chars(test_input: str, expected: str) -> None:
|
||||
assert pylast._remove_invalid_xml_chars(test_input) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_input, expected",
|
||||
[
|
||||
(
|
||||
# Plain text
|
||||
'<album mbid="">test album name</album>',
|
||||
'<?xml version="1.0" ?><album mbid="">test album name</album>',
|
||||
),
|
||||
(
|
||||
# Contains Unicode ENQ Enquiry control character
|
||||
'<album mbid="">test album \u0005name</album>',
|
||||
'<?xml version="1.0" ?><album mbid="">test album name</album>',
|
||||
),
|
||||
],
|
||||
)
|
||||
def test__parse_response(test_input: str, expected: str) -> None:
|
||||
doc = pylast._parse_response(test_input)
|
||||
assert doc.toxml() == expected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue