Example #1
0
    def test_parse_filter_or(self):
        pred = search._parse_filter([
            'OR', {
                'plot.width': {
                    'MIN': 5,
                    'MAX': {
                        'VALUE': 9,
                        'EXCLUSIVE': False
                    }
                },
                'tree.height': 9
            }, {
                'tree.leaf_type': {
                    'IS': 9
                },
                'tree.last_updated_by': 4
            }
        ],
                                    mapping=search.DEFAULT_MAPPING)

        p1 = ('AND',
              frozenset({('width__lte', 9), ('width__gte', 5),
                         ('tree__height', 9)}))

        p2 = ('AND',
              frozenset({('tree__leaf_type', 9),
                         ('tree__last_updated_by', 4)}))

        self.assertEqual(self.destructure_query_set(pred), ('OR', {p1, p2}))
Example #2
0
    def test_parse_filter_no_wrapper(self):
        pred = search._parse_filter(
            {'plot.width':
             {'MIN': 5,
              'MAX': {'VALUE': 9,
                      'EXCLUSIVE': False}},
             'tree.height': 9})

        p = ('AND',
             {('width__lte', 9),
              ('width__gte', 5),
              ('tree__height', 9)})

        self.assertEqual(self.destructure_query_set(pred), p)
Example #3
0
    def test_parse_filter_no_wrapper(self):
        pred = search._parse_filter(
            {'plot.width':
             {'MIN': 5,
              'MAX': {'VALUE': 9,
                      'EXCLUSIVE': False}},
             'tree.height': 9},
            mapping=search.DEFAULT_MAPPING)

        p = ('AND',
             {('width__lte', 9),
              ('width__gte', 5),
              ('tree__height', 9)})

        self.assertEqual(self.destructure_query_set(pred), p)
Example #4
0
    def test_parse_filter_or(self):
        pred = search._parse_filter(
            ['OR',
             {'plot.width':
              {'MIN': 5,
               'MAX': {'VALUE': 9,
                       'EXCLUSIVE': False}},
              'tree.height': 9},
             {'tree.leaf_type': {'IS': 9},
              'tree.last_updated_by': 4}])

        p1 = ('AND', frozenset({('width__lte', 9),
                                ('width__gte', 5),
                                ('tree__height', 9)}))

        p2 = ('AND', frozenset({('tree__leaf_type', 9),
                                ('tree__last_updated_by', 4)}))

        self.assertEqual(self.destructure_query_set(pred), ('OR', {p1, p2}))
Example #5
0
    def test_parse_filter_and(self):
        pred = search._parse_filter(
            ['AND',
             {'plot.width':
              {'MIN': 5,
               'MAX': {'VALUE': 9,
                       'EXCLUSIVE': False}},
              'tree.height': 9},
             {'tree.leaf_type': {'IS': 9},
              'tree.last_updated_by': 4}],
            mapping=search.DEFAULT_MAPPING)

        p = ('AND',
             {('width__lte', 9),
              ('width__gte', 5),
              ('tree__height', 9),
              ('tree__leaf_type', 9),
              ('tree__last_updated_by', 4)})

        self.assertEqual(self.destructure_query_set(pred), p)