-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from liangliangyy/dev
完善测试,为非本站链接自动添加nofollow
- Loading branch information
Showing
10 changed files
with
180 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[run] | ||
source = . | ||
include = *.py | ||
omit = | ||
*migrations* | ||
*tests* | ||
*.html | ||
*whoosh_cn_backend* | ||
*apps* | ||
*commands* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
from django.test import TestCase | ||
from django.test import Client, RequestFactory, TestCase | ||
from blog.models import Article, Category, Tag | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.sites.models import Site | ||
import datetime | ||
from accounts.models import BlogUser | ||
|
||
|
||
# Create your tests here. | ||
|
||
class AccountTest(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
self.factory = RequestFactory() | ||
|
||
def test_validate_account(self): | ||
site = Site.objects.get_current().domain | ||
user = BlogUser.objects.create_superuser(email="liangliangyy1@gmail.com", | ||
username="liangliangyy1", password="liangliangyy1") | ||
|
||
self.client.login(username='liangliangyy1', password='liangliangyy1') | ||
response = self.client.get('/admin/') | ||
self.assertEqual(response.status_code, 200) | ||
|
||
category = Category() | ||
category.name = "categoryaaa" | ||
category.created_time = datetime.datetime.now() | ||
category.last_mod_time = datetime.datetime.now() | ||
category.save() | ||
|
||
article = Article() | ||
article.title = "nicetitleaaa" | ||
article.body = "nicecontentaaa" | ||
article.author = user | ||
article.category = category | ||
article.type = 'a' | ||
article.status = 'p' | ||
article.save() | ||
|
||
response = self.client.get(article.get_admin_url()) | ||
self.assertEqual(response.status_code, 200) |
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 |
---|---|---|
@@ -1,3 +1,61 @@ | ||
from django.test import TestCase | ||
from django.test import Client, RequestFactory, TestCase | ||
from blog.models import Article, Category, Tag | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.sites.models import Site | ||
from django.core.urlresolvers import reverse | ||
import datetime | ||
from accounts.models import BlogUser | ||
|
||
|
||
# Create your tests here. | ||
|
||
class CommentsTest(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
self.factory = RequestFactory() | ||
|
||
def test_validate_comment(self): | ||
site = Site.objects.get_current().domain | ||
user = BlogUser.objects.create_superuser(email="liangliangyy1@gmail.com", | ||
username="liangliangyy1", password="liangliangyy1") | ||
|
||
self.client.login(username='liangliangyy1', password='liangliangyy1') | ||
|
||
category = Category() | ||
category.name = "categoryccc" | ||
category.created_time = datetime.datetime.now() | ||
category.last_mod_time = datetime.datetime.now() | ||
category.save() | ||
|
||
article = Article() | ||
article.title = "nicetitleccc" | ||
article.body = "nicecontentccc" | ||
article.author = user | ||
article.category = category | ||
article.type = 'a' | ||
article.status = 'p' | ||
article.save() | ||
|
||
commenturl = reverse('comments:postcomment', kwargs={'article_id': article.id}) | ||
|
||
response = self.client.post(commenturl, | ||
{ | ||
'body': '123ffffffffff' | ||
}) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
|
||
article = Article.objects.get(pk=article.pk) | ||
self.assertEqual(len(article.comment_list()), 0) | ||
|
||
response = self.client.post(commenturl, | ||
{ | ||
'body': '123ffffffffff', | ||
'email': user.email, | ||
'name': user.username | ||
}) | ||
|
||
self.assertEqual(response.status_code, 302) | ||
|
||
article = Article.objects.get(pk=article.pk) | ||
self.assertEqual(len(article.comment_list()), 1) |
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