Пример #1
0
    def test_clone(self):
        """ Verify that clone copies all fields, including the aggregation_key and distinct_hit_count."""
        query = DistinctCountsSearchQuery()
        query.add_field_facet('pacing_type')
        query.aggregation_key = 'aggregation_key'
        query._distinct_hit_count = 123

        clone = query._clone()
        assert query.facets == clone.facets
        assert query.aggregation_key == clone.aggregation_key
        assert query._distinct_hit_count == clone._distinct_hit_count
Пример #2
0
    def test_clone_with_different_class(self):
        """ Verify that clone does not copy aggregation_key and distinct_hit_count when using different class."""
        query = DistinctCountsSearchQuery()
        query.add_field_facet('pacing_type')
        query.aggregation_key = 'aggregation_key'
        query._distinct_hit_count = 123

        clone = query._clone(klass=ElasticsearchSearchQuery)
        assert isinstance(clone, ElasticsearchSearchQuery)
        assert query.facets == clone.facets
        assert not hasattr(clone, 'aggregation_key')
        assert not hasattr(clone, '_distinct_hit_count')