Commit d81da9df by Jay Zoldak

Add tests for django comment client mustache helpers

parent 593b0387
...@@ -5,6 +5,8 @@ import urllib ...@@ -5,6 +5,8 @@ import urllib
import sys import sys
import inspect import inspect
# This method is used to pluralize the words "discussion" and "comment"
# which is why you need to tack on an "s" for the case of 0 or two or more.
def pluralize(content, text): def pluralize(content, text):
num, word = text.split(' ') num, word = text.split(' ')
num = int(num or '0') num = int(num or '0')
......
import string
import random
import collections
from django.test import TestCase
import django_comment_client.mustache_helpers as mustache_helpers
class PluralizeTestCase(TestCase):
def test_pluralize(self):
self.text1 = '0 goat'
self.text2 = '1 goat'
self.text3 = '7 goat'
self.content = 'unused argument'
self.assertEqual(mustache_helpers.pluralize(self.content, self.text1), 'goats')
self.assertEqual(mustache_helpers.pluralize(self.content, self.text2), 'goat')
self.assertEqual(mustache_helpers.pluralize(self.content, self.text3), 'goats')
class CloseThreadTextTestCase(TestCase):
def test_close_thread_text(self):
self.contentClosed = {'closed': True}
self.contentOpen = {'closed': False}
self.assertEqual(mustache_helpers.close_thread_text(self.contentClosed), 'Re-open thread')
self.assertEqual(mustache_helpers.close_thread_text(self.contentOpen), 'Close thread')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment