From 593b038780e261f10e9dbc704e16db0df5700a47 Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Tue, 29 Jan 2013 14:43:28 -0500 Subject: [PATCH] Add tests for django-comment-client helpers --- lms/djangoapps/django_comment_client/helpers.py | 3 +++ .../django_comment_client/tests/test_helpers.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 lms/djangoapps/django_comment_client/tests/test_helpers.py diff --git a/lms/djangoapps/django_comment_client/helpers.py b/lms/djangoapps/django_comment_client/helpers.py index 96fd82d37c..0a1e8639ef 100644 --- a/lms/djangoapps/django_comment_client/helpers.py +++ b/lms/djangoapps/django_comment_client/helpers.py @@ -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' diff --git a/lms/djangoapps/django_comment_client/tests/test_helpers.py b/lms/djangoapps/django_comment_client/tests/test_helpers.py new file mode 100644 index 0000000000..bd67830841 --- /dev/null +++ b/lms/djangoapps/django_comment_client/tests/test_helpers.py @@ -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")