Add tests for django-comment-client helpers

This commit is contained in:
Jay Zoldak
2013-01-29 14:43:28 -05:00
parent 1f049410ae
commit 593b038780
2 changed files with 18 additions and 0 deletions

View File

@@ -12,6 +12,9 @@ import pystache_custom as pystache
import urllib
import os
# This method is used to pluralize the words "discussion" and "comment"
# when referring to how many discussion threads or comments the user
# has contributed to.
def pluralize(singular_term, count):
if int(count) >= 2 or int(count) == 0:
return singular_term + 's'

View File

@@ -0,0 +1,15 @@
import string
import random
import collections
from django.test import TestCase
from django_comment_client.helpers import pluralize
class PluralizeTestCase(TestCase):
def testPluralize(self):
self.term = "cat"
self.assertEqual(pluralize(self.term, 0), "cats")
self.assertEqual(pluralize(self.term, 1), "cat")
self.assertEqual(pluralize(self.term, 2), "cats")