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
woojing
authored and
정경업
committed
Feb 4, 2015
1 parent
713e03d
commit 1b48711
Showing
1 changed file
with
25 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,3 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.core.urlresolvers import reverse | ||
from django.test import TestCase | ||
from blog.models import Post | ||
|
||
# Create your tests here. | ||
|
||
class TestPostModel(TestCase): | ||
def _create_post(self): | ||
Post.objects.create(title=u'테스트', | ||
content=u'내용') | ||
|
||
def test_create_post_model(self): | ||
self._create_post() | ||
posts = Post.objects.all() | ||
self.assertEqual(len(posts), 1) | ||
post = posts[0] | ||
self.assertEqual(post.title, u'테스트') | ||
self.assertEqual(post.content, u'내용') | ||
|
||
def test_basic_listing(self): | ||
self._create_post() | ||
response = self.client.get(reverse('home')) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(len(response.context['object_list']), 1) | ||
object_list = response.context['object_list'] | ||
post = object_list[0] | ||
self.assertEqual(post.title, u'테스트') |
1b48711
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트를 돌려봅니다.
$ ./manage.py test
문제가 없는지 확인해보고, 없다면 문제를 만들어보기도 해봅시다.