コード例 #1
0
    def test_composite_filter_from_repr(property_filters):
        original_filter = CompositeFilter(
            operator=CompositeFilterOperator.AND,
            filters=[Filter(property_filters[0]),
                     Filter(property_filters[1])])
        data = {
            'op':
            original_filter.operator,
            'filters': [
                {
                    'propertyFilter': {
                        'property': {
                            'name':
                            original_filter.filters[0].inner_filter.prop
                        },
                        'op': original_filter.filters[0].inner_filter.operator,
                        'value': property_filters[0].value.to_repr()
                    }
                },
                {
                    'propertyFilter': {
                        'property': {
                            'name':
                            original_filter.filters[1].inner_filter.prop
                        },
                        'op': original_filter.filters[1].inner_filter.operator,
                        'value': property_filters[1].value.to_repr()
                    }
                },
            ]
        }

        output_filter = CompositeFilter.from_repr(data)

        assert output_filter == original_filter
コード例 #2
0
ファイル: filter_test.py プロジェクト: wgrabill/gcloud-aio
 def composite_filter(property_filters) -> CompositeFilter:
     return CompositeFilter(
         operator=CompositeFilterOperator.AND,
         filters=[
             Filter(property_filters[0]),
             Filter(property_filters[1])
         ])
コード例 #3
0
ファイル: filter_test.py プロジェクト: todddialpad/gcloud-aio
    def test_composite_filter_from_repr(property_filters):
        # pylint: disable=line-too-long
        original_filter = CompositeFilter(operator=CompositeFilterOperator.AND,
                                          filters=[
                                              Filter(property_filters[0]),
                                              Filter(property_filters[1]),
                                          ])
        data = {
            'op':
            original_filter.operator,
            'filters': [
                {
                    'propertyFilter': {
                        'property': {
                            'name':
                            original_filter.filters[0].inner_filter.prop,
                        },
                        'op': original_filter.filters[0].inner_filter.operator,
                        'value': property_filters[0].value.to_repr(),
                    },
                },
                {
                    'propertyFilter': {
                        'property': {
                            'name':
                            original_filter.filters[1].inner_filter.prop,
                        },
                        'op': original_filter.filters[1].inner_filter.operator,
                        'value': property_filters[1].value.to_repr(),
                    },
                },
            ],
        }

        output_filter = CompositeFilter.from_repr(data)

        assert output_filter == original_filter
コード例 #4
0
    def test_composite_filter_to_repr(self, property_filters):
        composite_filter = CompositeFilter(
            operator=CompositeFilterOperator.AND,
            filters=[Filter(property_filters[0]),
                     Filter(property_filters[1])])
        query_filter = Filter(composite_filter)

        r = query_filter.to_repr()

        composite_filter_dict = r['compositeFilter']
        assert composite_filter_dict['op'] == 'AND'
        self._assert_is_correct_prop_dict_for_property_filter(
            composite_filter_dict['filters'][0]['propertyFilter'],
            property_filters[0])
        self._assert_is_correct_prop_dict_for_property_filter(
            composite_filter_dict['filters'][1]['propertyFilter'],
            property_filters[1])