def test_normalize_filter(): # ensure we can properly normalize queries FIXME[matt] move to the agent cases = [ (None, {}), ( {"team":"leafs"}, {"team": "?"}, ), ( {"age": {"$gt" : 20}}, {"age": {"$gt" : "?"}}, ), ( {"age": {"$gt" : 20}}, {"age": {"$gt" : "?"}}, ), ( {"_id": {"$in" : [1, 2, 3]}}, {"_id": {"$in" : "?"}}, ), ( {"_id": {"$nin" : [1, 2, 3]}}, {"_id": {"$nin" : "?"}}, ), ( 20, {}, ), ( { "status": "A", "$or": [ { "age": { "$lt": 30 } }, { "type": 1 } ] }, { "status": "?", "$or": [ { "age": { "$lt": "?" } }, { "type": "?" } ] } ) ] for i, expected in cases: out = normalize_filter(i) eq_(expected, out)
def test_normalize_filter(): # ensure we can properly normalize queries FIXME[matt] move to the agent cases = [ (None, {}), ( {'team': 'leafs'}, {'team': '?'}, ), ( {'age': {'$gt': 20}}, {'age': {'$gt': '?'}}, ), ( {'age': {'$gt': 20}}, {'age': {'$gt': '?'}}, ), ( {'_id': {'$in': [1, 2, 3]}}, {'_id': {'$in': '?'}}, ), ( {'_id': {'$nin': [1, 2, 3]}}, {'_id': {'$nin': '?'}}, ), ( 20, {}, ), ( { 'status': 'A', '$or': [{'age': {'$lt': 30}}, {'type': 1}], }, { 'status': '?', '$or': [{'age': {'$lt': '?'}}, {'type': '?'}], }, ), ] for i, expected in cases: out = normalize_filter(i) assert expected == out