-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
f624a31
commit 46dad62
Showing
8 changed files
with
103 additions
and
14 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
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,10 @@ | ||
from rest_framework import status | ||
from .base_test import BaseTestCase | ||
|
||
class TestDeleteArticle(BaseTestCase): | ||
def test_successful_article_deletion(self): | ||
self.user_signup() | ||
token='Token ' + self.user_login() | ||
self.test_client.post(self.articles_url, self.article_data, format='json', HTTP_AUTHORIZATION=token) | ||
response = self.test_client.delete(self.article_url, HTTP_AUTHORIZATION=token) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.urls import reverse | ||
from rest_framework import status | ||
from .base_test import BaseTestCase | ||
|
||
class TestPostArticle(BaseTestCase): | ||
|
||
def test_successful_get_creation(self): | ||
# valid data | ||
self.user_signup() | ||
token='Token ' + self.user_login() | ||
self.test_client.post(self.articles_url, self.article_data, format='json', HTTP_AUTHORIZATION=token) | ||
response = self.test_client.get(self.articles_url, HTTP_AUTHORIZATION=token) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def test_get_article(self): | ||
self.user_signup() | ||
token='Token ' + self.user_login() | ||
# print('-----------------------{}---------------------------'.format(token)) | ||
|
||
self.test_client.post(self.articles_url, self.article_data, format='json', HTTP_AUTHORIZATION=token) | ||
response = self.test_client.get(self.article_url, HTTP_AUTHORIZATION=token) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
def test_get_non_existing_article(self): | ||
self.user_signup() | ||
token = 'Token '+ self.user_login() | ||
self.test_client.post(self.articles_url, self.article_data, format='json', HTTP_AUTHORIZATION=token) | ||
response = self.test_client.get("articles/10") | ||
print("*"*20, response) | ||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | ||
|
||
|
||
|
||
|
||
|
||
|
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,32 @@ | ||
from rest_framework import status | ||
from .base_test import BaseTestCase | ||
|
||
class TestPostArticle(BaseTestCase): | ||
def test_successful_article_creation(self): | ||
# valid data | ||
self.user_signup() | ||
token='Token ' + self.user_login() | ||
response = self.test_client.post(self.articles_url, self.article_data, format='json', HTTP_AUTHORIZATION=token) | ||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
|
||
def test_post_using_invalid_data(self): | ||
self.user_signup() | ||
token='Token ' + self.user_login() | ||
response = self.test_client.post(self.articles_url, self.article_invalid_data, format='json', HTTP_AUTHORIZATION=token) | ||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
def test_without_authentication(self): | ||
self.user_signup() | ||
response = self.test_client.post(self.articles_url, self.article_invalid_data, format='json') | ||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) | ||
|
||
# Post | ||
# Test article creation with valid data | ||
# Test article with invalid data | ||
# Test article with | ||
# Get | ||
# | ||
# Put | ||
# | ||
# Delete | ||
# |
Empty file.
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