def test_where(): data = [{'a': 1, 'b': 2}, {'a': 10, 'b': 2}] assert where(data, a=1) == [{'a': 1, 'b': 2}] assert where(data, a=1, b=2) == [{'a': 1, 'b': 2}] assert where(data, b=2) == data
def find_api(method_name): """ Given a method name, find its API. """ endpoint = first(where(api_methods, method=method_name)) if endpoint: return endpoint.get('api')
def test_where_nonexistent_key(): data = [{'a': 1}, {'b': 2}] assert where(data, a=1) == [{'a': 1}] assert where(data, b=2) == [{'b': 2}]