def test_group_count(self): q = Query() q.group('field', count=True) assert q._pipeline[-1] == { '$group': { '_id': '$field', 'count': { '$sum': 1 } } }
def test_group_list(self): q = Query() q.group(['field1', 'field2']) assert q._pipeline[-1] == { '$group': { '_id': { 'field1': '$field1', 'field2': '$field2' } } }
def test_group_str(self): q = Query() q.group("field") assert q._pipeline[-1] == {'$group': {"_id": "$field"}}