Example #1
0
 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'
                                  }
                              }
                          }])
Example #2
0
 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)')
Example #3
0
 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)')
Example #4
0
 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'}}}])