My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase

from models import Author

class AuthorTest(TestCase):

fixtures = ['test_data.json']

def test_author_listing(self):
"""
Verify that the author listing page contains all author names within the
page's context.
"""
response = self.client.get(reverse("authors:list"))
self.failUnlessEqual(response.status_code, 200)
try:
response.context['author_list']
except KeyError:
self.fail("Template context did not contain author_list object.")
for author in Author.objects.all():
self.assertTrue(author in response.context['author_list'])

def test_verify_author_detail_pages(self):
"""
Verify that each author has a detail page and that the author is
contained within the page's context.
"""
for author in Author.objects.all():
response = self.client.get(author.get_absolute_url())
self.assertTrue(response.status_code == 200)
try:
self.failUnlessEqual(response.context['author'], author)
except KeyError:
self.fail("Template context did not contain author object.")

def test_author_repr(self):
"""
Verify that authors are represented correctly, even when user has no
first or last name.
"""
new_user = User.objects.create_user('testusername', 't@t.com', 'pass')
new_user.save()
new_author = Author(user=new_user, slug="testusername")
new_author.save()
# If no user first/last name, show username:
self.failUnlessEqual(new_author.__unicode__(), 'testusername')
new_user.first_name = "Test"
new_user.last_name = "User"
new_user.save()
# Now shoudl be full name:
self.failUnlessEqual(new_author.__unicode__(), 'Test User')

Change log

r40 by james.m.stevenson on Dec 9, 2009   Diff
fixes broken test
Go to: 
Project members, sign in to write a code review

Older revisions

r39 by james.m.stevenson on Dec 9, 2009   Diff
* Many CSS improvements
* tagging views and templates added
* bug fix for twitter messaging in
admin
* site search templting improvements
...
r21 by james.m.stevenson on Nov 24, 2009   Diff
* Adds test data set for blogging app
* Improves tests for blogs
* Fixes test failure in authors app
* Adds 404.html template
r16 by james.m.stevenson on Nov 19, 2009   Diff
* Adds implements tumblelog part of
blogging app, templates
* Adds tests, helpful utils to authors
app
* Adds test data to site prefs app
...
All revisions of this file

File info

Size: 2020 bytes, 53 lines
Powered by Google Project Hosting