Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_collection_provider_parses_query_and_returns_list(self):
col = ["a", "b"]
query = From(col).where("item == 'a'")
provider = query.provider
assert isinstance(provider.parse(query, Actions.SelectMany), list)
def test_collection_provider_parses_query_using_lesser_than(self):
col = range(5)
query = From(col).where("item <= 3")
provider = query.provider
result = provider.parse(query, Actions.SelectMany)
assert result == range(4), "The collection was not filtered properly and now is: %s" % result
def parse(self, query, action, **kwargs):
if action == Actions.SelectMany:
return self.parse_select_many(query)
elif action == Actions.Select:
return self.parse_select(query, kwargs["cols"])
elif action == Actions.Count:
return self.parse_count(query)
elif action == Actions.Max:
return self.parse_max(query, kwargs["column"])
elif action == Actions.Min:
return self.parse_min(query, kwargs["column"])
elif action == Actions.Sum:
return self.parse_sum(query, kwargs["column"])
elif action == Actions.Avg:
return self.parse_avg(query, kwargs["column"])
else:
raise ValueError("Invalid action exception. %s is unknown." % action)
def select_many(self):
return self.provider.parse(self, action=Actions.SelectMany)