Mercurial > public > sg101
annotate gpp/antispam/tests.py @ 258:f9a9b4014d5b
Fix #111: some shoutbox templates still using old non-GET pagination scheme.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 21 Sep 2010 23:08:36 +0000 |
parents | 28988cce138b |
children |
rev | line source |
---|---|
bgneal@214 | 1 """ |
bgneal@214 | 2 Tests for the antispam application. |
bgneal@214 | 3 """ |
bgneal@214 | 4 from django.test import TestCase |
bgneal@214 | 5 from django.core.cache import cache |
bgneal@214 | 6 |
bgneal@214 | 7 from antispam import SPAM_PHRASE_KEY |
bgneal@214 | 8 from antispam.models import SpamPhrase |
bgneal@214 | 9 from antispam.utils import contains_spam |
bgneal@214 | 10 |
bgneal@214 | 11 |
bgneal@214 | 12 class AntispamCase(TestCase): |
bgneal@214 | 13 |
bgneal@214 | 14 def test_no_phrases(self): |
bgneal@214 | 15 """ |
bgneal@214 | 16 Tests that an empty spam phrase table works. |
bgneal@214 | 17 """ |
bgneal@214 | 18 cache.delete(SPAM_PHRASE_KEY) |
bgneal@214 | 19 self.assertFalse(contains_spam("Here is some random text.")) |
bgneal@214 | 20 |
bgneal@214 | 21 def test_phrases(self): |
bgneal@214 | 22 """ |
bgneal@214 | 23 Simple test of some phrases. |
bgneal@214 | 24 """ |
bgneal@214 | 25 SpamPhrase.objects.create(phrase="grytner") |
bgneal@214 | 26 SpamPhrase.objects.create(phrase="allday.ru") |
bgneal@214 | 27 SpamPhrase.objects.create(phrase="stefa.pl") |
bgneal@214 | 28 |
bgneal@214 | 29 self.assert_(contains_spam("grytner")) |
bgneal@214 | 30 self.assert_(contains_spam("11grytner")) |
bgneal@214 | 31 self.assert_(contains_spam("11grytner>")) |
bgneal@214 | 32 self.assert_(contains_spam("1djkl jsd stefa.pl")) |
bgneal@214 | 33 self.assert_(contains_spam("1djkl jsd <stefa.pl---sd8")) |
bgneal@214 | 34 self.assert_(contains_spam("1dsdjallday.rukl jsd <stefa.pl---sd8")) |
bgneal@214 | 35 self.assert_(contains_spam(" 1djallday.rukl")) |
bgneal@214 | 36 self.assertFalse(contains_spam("this one is spam free.")) |
bgneal@214 | 37 |