Commit 4f13cfe3 authored by okhin's avatar okhin 🚴

Using the article title seems a better way to test the search for now

parent 6b5e39e3
...@@ -13,6 +13,7 @@ class ArticleViewSet(ArticleMixin, viewsets.ModelViewSet): ...@@ -13,6 +13,7 @@ class ArticleViewSet(ArticleMixin, viewsets.ModelViewSet):
queryset = Article.objects.all() queryset = Article.objects.all()
serializer_class = ArticleSerializer serializer_class = ArticleSerializer
class ArticleSearch(viewsets.ModelViewSet, mixins.ListModelMixin): class ArticleSearch(viewsets.ModelViewSet, mixins.ListModelMixin):
queryset = Article.objects.all() queryset = Article.objects.all()
serializer_class = ArticleSerializer serializer_class = ArticleSerializer
...@@ -22,6 +23,7 @@ class ArticleSearch(viewsets.ModelViewSet, mixins.ListModelMixin): ...@@ -22,6 +23,7 @@ class ArticleSearch(viewsets.ModelViewSet, mixins.ListModelMixin):
| Q(extracts__icontains=kwargs['search_keywords'])) | Q(extracts__icontains=kwargs['search_keywords']))
return super().list(request, args, kwargs) return super().list(request, args, kwargs)
class ArticleTag(viewsets.ModelViewSet, mixins.ListModelMixin): class ArticleTag(viewsets.ModelViewSet, mixins.ListModelMixin):
queryset = Article.objects.all() queryset = Article.objects.all()
serializer_class = ArticleSerializer serializer_class = ArticleSerializer
......
...@@ -116,7 +116,8 @@ class TestArticleApi(TestCase): ...@@ -116,7 +116,8 @@ class TestArticleApi(TestCase):
assert r.data['count'] == 0 assert r.data['count'] == 0
def test_api_filter_search(self): def test_api_filter_search(self):
text = ' '.join(self.articles[0].extracts.split(' ')) #text = ' '.join(self.articles[0].extracts.split(' ')[:10])
text = self.articles[0].title
r = self.client.get('/api/articles-search/{}/'.format(text)) r = self.client.get('/api/articles-search/{}/'.format(text))
assert r.status_code == 200 assert r.status_code == 200
assert r.data['count'] == 1 assert r.data['count'] == 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment