Skip to content

Commit

Permalink
BUG: Fix empty set returned from validate_query (Fixes #102)
Browse files Browse the repository at this point in the history
Manually cast set of variables to bool when returning.
  • Loading branch information
dopplershift committed Jul 21, 2017
1 parent e61c876 commit df3102b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit df3102b

Please sign in to comment.