use Translation objects in the tests

This commit is contained in:
Jeff Balogh 2010-08-05 15:46:29 -07:00
Родитель 960cbb046f
Коммит 459fe4f45d
2 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -23,7 +23,7 @@ class ReviewsRss(Feed):
def title(self, addon):
"""Title for the feed"""
return _('Reviews for %s') % addon.name
return _(u'Reviews for %s') % addon.name
def link(self, addon):
"""Link for the feed"""
@ -52,7 +52,7 @@ class ReviewsRss(Feed):
if getattr(review, 'title', None):
tag_line = review.title
divider = ' : ' if rating and tag_line else ''
return rating + divider + tag_line
return u'%s%s%s' % (rating, divider, tag_line)
def item_description(self, review):
"""Description for particular review (<item><description>)"""

Просмотреть файл

@ -4,6 +4,7 @@ import test_utils
from nose.tools import eq_
from reviews import feeds
from translations.models import Translation
class FeedTest(test_utils.TestCase):
@ -11,15 +12,16 @@ class FeedTest(test_utils.TestCase):
def setUp(self):
self.feed = feeds.ReviewsRss()
self.wut = u'Ελληνικά'
self.u = u'Ελληνικά'
self.wut = Translation(localized_string=self.u, locale='el')
self.addon = mock.Mock()
self.addon.name = self.wut
self.user = mock.Mock()
self.user.nickname = None
self.user.firstname = self.wut
self.user.lastname = self.wut
self.user.firstname = self.u
self.user.lastname = self.u
self.review = mock.Mock()
self.review.title = self.wut
@ -28,18 +30,18 @@ class FeedTest(test_utils.TestCase):
def test_title(self):
eq_(self.feed.title(self.addon),
'Reviews for %s' % self.wut)
u'Reviews for %s' % self.u)
def test_item_title(self):
eq_(self.feed.item_title(self.review),
'Rated %s out of 5 stars : %s' % (self.review.rating, self.wut))
'Rated %s out of 5 stars : %s' % (self.review.rating, self.u))
self.review.rating = None
eq_(self.feed.item_title(self.review), self.wut)
eq_(self.feed.item_title(self.review), self.u)
def test_item_author_name(self):
eq_(self.feed.item_author_name(self.review),
'%s %s' % (self.wut, self.wut))
'%s %s' % (self.u, self.u))
self.user.nickname = self.wut
eq_(self.feed.item_author_name(self.review), self.wut)
self.user.nickname = self.u
eq_(self.feed.item_author_name(self.review), self.u)