From 8486805b982b49c1a12f28945ec7346a605d0f5b Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Wed, 5 Dec 2012 12:12:11 +0100 Subject: Snip quoted text in replies --- hyperkitty/tests/__init__.py | 1 + hyperkitty/tests/test_templatetags.py | 64 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 hyperkitty/tests/test_templatetags.py (limited to 'hyperkitty/tests') 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 . +# +# Author: Aurelien Bompard +# + +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: +> This is the first quoted line +> This is the second quoted line +This is the response. +""" + expected = """ +On Fri, 09.11.12 11:27, Someone wrote: +%s +> This is the first quoted line +> This is the second quoted line +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: + +> This is the first quoted line +> This is the second quoted line +This is the response. +""" + expected = """ +On Fri, 09.11.12 11:27, Someone wrote: +%s +> This is the first quoted line +> This is the second quoted line +This is the response. +""" % self.quotemsg + result = snip_quoted(contents, self.quotemsg) + self.assertEqual(result, expected) -- cgit