def test_get_es_filter_fields(self): view = ElasticAPIView() assert view.get_es_filter_fields() == tuple() es_filter_fields = ('first_name', 'last_name') view.es_filter_fields = es_filter_fields assert view.get_es_filter_fields() == es_filter_fields
def test_get_es_filter_fields(self): view = ElasticAPIView() view.es_filter_backends = (ElasticFieldsFilter, ) view.es_filter_fields = (ESFieldFilter('score'), ESFieldFilter('description')) self.inspector.view = view for fields in (self.inspector.get_es_filter_fields('/', 'GET'), self.inspector.get_filter_fields('/', 'GET')): field_names = [field.name for field in fields] assert sorted(field_names) == ['description', 'score']
def create_view(self, es_filter_fields): """Create and return test view class instance Args: es_filter_fields ([ESFieldFilter]): filtering fields Returns: ElasticAPIView: test view instance """ view = ElasticAPIView() view.es_model = DataDocType view.es_filter_fields = es_filter_fields return view
def test_get_link(self): view = ElasticAPIView() view.es_filter_backends = (ElasticFieldsFilter, ElasticFieldsRangeFilter, ElasticOrderingFilter, ElasticSearchFilter) view.es_filter_fields = (ESFieldFilter('score'), ESFieldFilter('description')) view.es_range_filter_fields = (ESFieldFilter('date'), ) view.es_pagination_class = es_pagination.ElasticLimitOffsetPagination self.inspector.view = view link = self.inspector.get_link('/', 'GET', 'localhost') field_names = [field.name for field in link.fields] assert sorted(field_names) == [ 'date', 'description', 'limit', 'offset', 'ordering', 'score', 'search' ]