Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix empty set returned from validate_query (Fixes #102) #143

Merged
merged 1 commit into from
Jul 22, 2017
Merged
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 siphon/ncss.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def validate_query(self, query):

"""
# Make sure all variables are in the dataset
return query.var and all(var in self.variables for var in query.var)
return bool(query.var) and all(var in self.variables for var in query.var)

def get_data(self, query):
"""Fetch parsed data from a THREDDS server using NCSS.
Expand Down
7 changes: 7 additions & 0 deletions siphon/tests/test_ncss.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def test_bad_query(self):
self.nq.variables('foo')
assert not self.ncss.validate_query(self.nq)

def test_empty_query(self):
"""Test that an empty query is invalid."""
query = self.ncss.query()
res = self.ncss.validate_query(query)
assert not res
assert not isinstance(res, set)

def test_bad_query_no_vars(self):
"""Test that a query without variables is invalid."""
self.nq.var.clear()
Expand Down