Exemplo n.º 1
0
 def test_succeed_on_parse_where(self):
   filter_with_inequalities = {'val1': { 'ge': 8, 'le': 17 }}
   filter_with_strict_inequalities = { 'val2': { 'lt': 9, 'gt':2} }
   filter_with_in = { 'color': {'in': ['blue', 'red']}}
   self.assertEqual(Parser.parse_where(filter_with_inequalities), [('val1', '>=', 8), ('val1', '<=', 17)])
   self.assertEqual(Parser.parse_where(filter_with_strict_inequalities), [('val2', '<', 9), ('val2', '>', 2)])
   self.assertEqual(Parser.parse_where(filter_with_in), [('color', 'in', ['blue', 'red'])])
Exemplo n.º 2
0
 def test_succeed_on_parse_where(self):
     filter_with_inequalities = {'val1': {'ge': 8, 'le': 17}}
     filter_with_strict_inequalities = {'val2': {'lt': 9, 'gt': 2}}
     filter_with_in = {'color': {'in': ['blue', 'red']}}
     self.assertEqual(Parser.parse_where(filter_with_inequalities),
                      [('val1', '>=', 8), ('val1', '<=', 17)])
     self.assertEqual(Parser.parse_where(filter_with_strict_inequalities),
                      [('val2', '<', 9), ('val2', '>', 2)])
     self.assertEqual(Parser.parse_where(filter_with_in),
                      [('color', 'in', ['blue', 'red'])])
Exemplo n.º 3
0
 def test_succeed_on_parse_order(self):
   order_asc = {u'sort': u'sum(val1)', u'asc': True }
   order_non_specicied_asc = {u'sort': u'sum(val1)' }
   self.assertEqual(Parser.parse_order(order_asc), ('sum(val1)', 'ASC'))
   self.assertEqual(Parser.parse_order(order_non_specicied_asc), ('sum(val1)', 'DESC'))
Exemplo n.º 4
0
 def test_succeed_on_parse_group(self):
   # Does same thing as parse_select
   group_as_str = 'group'
   group_as_lst = ['darth', 'vader']
   self.assertEqual(Parser.parse_group(group_as_str), 'group')
   self.assertEqual(Parser.parse_group(group_as_lst), 'darth, vader')
Exemplo n.º 5
0
 def test_succeed_on_parse_select(self):
   select_as_str = 'group'
   select_as_lst = ['darth', 'vader']
   self.assertEqual(Parser.parse_select(select_as_str), 'group')
   self.assertEqual(Parser.parse_select(select_as_lst), 'darth, vader')
Exemplo n.º 6
0
 def test_succeed_on_parse_group(self):
     # Does same thing as parse_select
     group_as_str = 'group'
     group_as_lst = ['darth', 'vader']
     self.assertEqual(Parser.parse_group(group_as_str), 'group')
     self.assertEqual(Parser.parse_group(group_as_lst), 'darth, vader')
Exemplo n.º 7
0
 def test_succeed_on_parse_select(self):
     select_as_str = 'group'
     select_as_lst = ['darth', 'vader']
     self.assertEqual(Parser.parse_select(select_as_str), 'group')
     self.assertEqual(Parser.parse_select(select_as_lst), 'darth, vader')
Exemplo n.º 8
0
 def test_succeed_on_parse_order(self):
     order_asc = {u'sort': u'sum(val1)', u'asc': True}
     order_non_specicied_asc = {u'sort': u'sum(val1)'}
     self.assertEqual(Parser.parse_order(order_asc), ('sum(val1)', 'ASC'))
     self.assertEqual(Parser.parse_order(order_non_specicied_asc),
                      ('sum(val1)', 'DESC'))