Skip to content

Commit

Permalink
기본 모델, 리스팅 테스트 케이스 추가
Browse files Browse the repository at this point in the history
  • 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.
26 changes: 25 additions & 1 deletion blog/tests.py
@@ -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'테스트')

1 comment on commit 1b48711

@perhapsspy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트를 돌려봅니다.
$ ./manage.py test

문제가 없는지 확인해보고, 없다면 문제를 만들어보기도 해봅시다.

Please sign in to comment.