summaryrefslogtreecommitdiffstats
path: root/hyperkitty/tests
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-12-05 12:12:11 +0100
committerAurélien Bompard <aurelien@bompard.org>2012-12-05 12:12:11 +0100
commit8486805b982b49c1a12f28945ec7346a605d0f5b (patch)
tree7965cdcbd4ee11a64425e4a73d6653e2592c2875 /hyperkitty/tests
parent716fee916da1096edb865bb43224594574d5a85b (diff)
downloadhyperkitty-8486805b982b49c1a12f28945ec7346a605d0f5b.tar.gz
hyperkitty-8486805b982b49c1a12f28945ec7346a605d0f5b.tar.xz
hyperkitty-8486805b982b49c1a12f28945ec7346a605d0f5b.zip
Snip quoted text in replies
Diffstat (limited to 'hyperkitty/tests')
-rw-r--r--hyperkitty/tests/__init__.py1
-rw-r--r--hyperkitty/tests/test_templatetags.py64
2 files changed, 65 insertions, 0 deletions
diff --git a/hyperkitty/tests/__init__.py b/hyperkitty/tests/__init__.py
index bf3e6b6..f3ee25f 100644
--- a/hyperkitty/tests/__init__.py
+++ b/hyperkitty/tests/__init__.py
@@ -22,3 +22,4 @@
from hyperkitty.tests.test_views import *
from hyperkitty.tests.test_models import *
from hyperkitty.tests.test_forms import *
+from hyperkitty.tests.test_templatetags import *
diff --git a/hyperkitty/tests/test_templatetags.py b/hyperkitty/tests/test_templatetags.py
new file mode 100644
index 0000000..1275b25
--- /dev/null
+++ b/hyperkitty/tests/test_templatetags.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 1998-2012 by the Free Software Foundation, Inc.
+#
+# This file is part of HyperKitty.
+#
+# HyperKitty is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# HyperKitty is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# HyperKitty. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Aurelien Bompard <abompard@fedoraproject.org>
+#
+
+from django.test import TestCase
+
+from hyperkitty.templatetags.hk_generic import snip_quoted
+
+class SnipQuotedTestCase(TestCase):
+
+ quotemsg = "[SNIP]"
+
+ def test_quote_1(self):
+ contents = """
+On Fri, 09.11.12 11:27, Someone wrote:
+&gt; This is the first quoted line
+&gt; This is the second quoted line
+This is the response.
+"""
+ expected = """
+On Fri, 09.11.12 11:27, Someone wrote:
+<a href="#" class="quoted-switch">%s</a><span class="quoted-text">
+&gt; This is the first quoted line
+&gt; This is the second quoted line</span>
+This is the response.
+""" % self.quotemsg
+ result = snip_quoted(contents, self.quotemsg)
+ self.assertEqual(result, expected)
+
+ def test_quote_2(self):
+ """The quote starts with a newline"""
+ contents = """
+On Fri, 09.11.12 11:27, Someone wrote:
+
+&gt; This is the first quoted line
+&gt; This is the second quoted line
+This is the response.
+"""
+ expected = """
+On Fri, 09.11.12 11:27, Someone wrote:
+<a href="#" class="quoted-switch">%s</a><span class="quoted-text">
+&gt; This is the first quoted line
+&gt; This is the second quoted line</span>
+This is the response.
+""" % self.quotemsg
+ result = snip_quoted(contents, self.quotemsg)
+ self.assertEqual(result, expected)