Beispiel #1
0
    def test_parse_predicate(self):
        pred = search._parse_scalar_predicate(
            {
                'plot.width': {
                    'MIN': 5,
                    'MAX': {
                        'VALUE': 9,
                        'EXCLUSIVE': False
                    }
                },
                'tree.height': 9
            },
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred), p1)

        pred = search._parse_scalar_predicate(
            {
                'tree.leaf_type': {
                    'IS': 9
                },
                'tree.last_updated_by': 4
            },
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred), p2)
Beispiel #2
0
    def test_parse_predicate(self):
        pred = search._parse_scalar_predicate(
            {'plot.width':
             {'MIN': 5,
              'MAX': {'VALUE': 9,
                      'EXCLUSIVE': False}},
             'tree.height': 9},
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred),
                         p1)

        pred = search._parse_scalar_predicate(
            {'tree.leaf_type': {'IS': 9},
             'tree.last_updated_by': 4},
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred),
                         p2)
Beispiel #3
0
    def test_like_predicate(self):
        pred = search._parse_scalar_predicate(
            {'tree.steward': {'LIKE': 'thisisatest'}},
            mapping=search.DEFAULT_MAPPING)

        target = ('AND', {('tree__steward__icontains', 'thisisatest')})

        self.assertEqual(destructure_query_set(pred), target)
Beispiel #4
0
    def test_parse_species_predicate(self):
        pred = search._parse_scalar_predicate(
            {'species.id': 113,
             'species.flowering': True},
            mapping=search.DEFAULT_MAPPING)

        target = ('AND', {('tree__species__id', 113),
                          ('tree__species__flowering', True)})

        self.assertEqual(destructure_query_set(pred), target)
Beispiel #5
0
    def test_like_predicate(self):
        pred = search._parse_scalar_predicate(
            {'tree.steward': {
                'LIKE': 'thisisatest'
            }},
            mapping=search.DEFAULT_MAPPING)

        target = ('AND', {('tree__steward__icontains', 'thisisatest')})

        self.assertEqual(destructure_query_set(pred), target)
Beispiel #6
0
    def test_parse_species_predicate(self):
        pred = search._parse_scalar_predicate(
            {
                'species.id': 113,
                'species.flowering': True
            },
            mapping=search.DEFAULT_MAPPING)

        target = ('AND', {('tree__species__id', 113),
                          ('tree__species__flowering', True)})

        self.assertEqual(destructure_query_set(pred), target)
Beispiel #7
0
    def test_parse_predicate_with_tree_map(self):
        pred = search._parse_scalar_predicate(
            {'plot.width':
             {'MIN': 5,
              'MAX': {'VALUE': 9,
                      'EXCLUSIVE': False}},
             'tree.height':
             9},
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred),
                         p1)
Beispiel #8
0
    def test_parse_predicate_with_tree_map(self):
        pred = search._parse_scalar_predicate(
            {
                'plot.width': {
                    'MIN': 5,
                    'MAX': {
                        'VALUE': 9,
                        'EXCLUSIVE': False
                    }
                },
                'tree.height': 9
            },
            mapping=search.DEFAULT_MAPPING)

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

        self.assertEqual(destructure_query_set(pred), p1)