-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
155 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
authors/apps/articles/migrations/0002_auto_20190319_0816.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 2.1.5 on 2019-03-19 08:16 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('profiles', '0001_initial'), | ||
('articles', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='rating', | ||
name='rated_by', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='scores', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='articlelikesdislikes', | ||
name='article', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='articles.Article'), | ||
), | ||
migrations.AddField( | ||
model_name='articlelikesdislikes', | ||
name='user', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='profiles.Profile'), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='author', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='author_articles', to='profiles.Profile'), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='favorites', | ||
field=models.ManyToManyField(blank=True, related_name='favorited_articles', to='profiles.Profile'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from django.urls import reverse | ||
|
||
from rest_framework import status | ||
|
||
from authors.apps.articles.tests.base_class import ArticlesBaseTest | ||
from .test_data import valid_article | ||
from ..models import Article | ||
|
||
|
||
class TestSearchArticle(ArticlesBaseTest): | ||
|
||
def test_search_by_keyword(self): | ||
""" | ||
Tests if a user can search articles by keyword | ||
""" | ||
self.add_article() | ||
response = self.client.get(self.articles_url+"?keyword=the") | ||
self.assertIn("the", response.data['articles'][0]['description']) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def test_search_by_tag(self): | ||
""" | ||
Tests if a user can search articles by tag | ||
""" | ||
self.add_tagged_article() | ||
response = self.client.get(self.articles_url+"?tag=apps") | ||
self.assertIn("apps", response.data['articles'][0]['tagList']) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def test_search_by_author(self): | ||
""" | ||
Tests if a user can search articles by an author | ||
""" | ||
self.add_tagged_article() | ||
response = self.client.get(self.articles_url+"?author=Bagzie12") | ||
self.assertIn("Bagzie12", response.data['articles'][0]['author']['username']) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters