Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion owslib/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __init__(self, md):
self.outputencoding = testXMLValue(val)

val = md.find(nspath_eval('os:Tags', namespaces))
self.tags = testXMLValue(val).split()
self.tags = (testXMLValue(val) or '').split()

val = md.find(nspath_eval('os:Contact', namespaces))
self.contact = testXMLValue(val)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_opensearch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

from owslib.opensearch import OpenSearch


@pytest.mark.parametrize('tags_xml, expected_tags', [
('', []),
('<Tags/>', []),
('<Tags> </Tags>', []),
('<Tags>earth observation</Tags>', ['earth', 'observation']),
])
def test_opensearch_description_optional_tags(tags_xml, expected_tags):
xml = f'''<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Example search</ShortName>
<Description>Search public observations</Description>
<Url type="application/atom+xml"
template="https://example.com/search?q={{searchTerms}}"/>
{tags_xml}
</OpenSearchDescription>'''

client = OpenSearch('https://example.com/opensearch', xml=xml)

assert client.description.tags == expected_tags
assert client.description.shortname == 'Example search'
assert client.description.urls['application/atom+xml']['template'] == (
'https://example.com/search?q={searchTerms}'
)