33from django .utils .timezone import utc
44from djagno .contrib .auth .models import User
55
6- from myblog .models import Post , Category
6+ from myblog .models import Post
77
88
99class FrontEndTestCase (TestCase ):
@@ -14,8 +14,6 @@ def setUp(self):
1414 self .now = datetime .datetime .utcnow ().replace (tzinfo = utc )
1515 self .timedelta = datetime .timedelta (15 )
1616 author = User .objects .get (pk = 1 )
17- self .category = Category (name = 'A Category' )
18- self .category .save ()
1917 for count in range (1 ,11 ):
2018 post = Post (title = "Post %d Title" % count ,
2119 text = "foo" ,
@@ -25,9 +23,6 @@ def setUp(self):
2523 pubdate = self .now - self .timedelta * count
2624 post .published_date = pubdate
2725 post .save ()
28- if bool (count & 1 ):
29- # put odd items in category:
30- self .category .posts .add (post )
3126
3227 def test_list_only_published (self ):
3328 resp = self .client .get ('/' )
@@ -48,13 +43,4 @@ def test_details_only_published(self):
4843 self .assertEqual (resp .status_code , 200 )
4944 self .assertContains (resp , title )
5045 else :
51- self .assertEqual (resp .status_code , 404 )
52-
53- def test_category_only_published (self ):
54- resp = self .client .get ('/category/%d/' % self .category .pk )
55- for count in range (1 ,11 ):
56- title = "Post %d Title" % count
57- if count < 6 and bool (count & 1 ):
58- self .assertContains (resp , title , count = 1 )
59- else :
60- self .assertNotContains (resp , title )
46+ self .assertEqual (resp .status_code , 404 )
0 commit comments