def test_group(self): for group_func in pql.AggregationGroupParser.GROUP_FUNCTIONS: self.assertEqual(pql.group(_id='foo', total=group_func + '(bar)'), [{ '$group': { '_id': '$foo', 'total': { '$' + group_func: '$bar' } } }])
def test_invalid_group(self): with self.assertRaises(pql.ParseError): pql.group(_id='foo', total='bar(1)') with self.assertRaises(pql.ParseError): pql.group(_id='foo', total='min(1, 2)')
def test_group(self): for group_func in pql.AggregationGroupParser.GROUP_FUNCTIONS: self.assertEqual(pql.group(_id='foo', total=group_func + '(bar)'), [{'$group': {'_id': '$foo', 'total': {'$' + group_func: '$bar'}}}])