allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [22/50] git commit: [#5571] Enable akismet and mollom EPs and improve conditional imports / tests
Date Fri, 24 May 2013 17:04:58 GMT
[#5571] Enable akismet and mollom EPs and improve conditional imports / tests

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/79642a38
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/79642a38
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/79642a38

Branch: refs/heads/db/6255
Commit: 79642a38869b4690ce839f3aa180aaf5f98c5c7a
Parents: 7af81dd
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed May 22 22:30:29 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed May 22 22:30:29 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/spam/akismetfilter.py       |    8 +++++++-
 Allura/allura/lib/spam/mollomfilter.py        |    8 +++++++-
 Allura/allura/tests/unit/spam/test_akismet.py |    7 ++-----
 Allura/allura/tests/unit/spam/test_mollom.py  |    8 +++-----
 Allura/setup.py                               |    4 ++--
 requirements-sf.txt                           |    1 +
 6 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/Allura/allura/lib/spam/akismetfilter.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/spam/akismetfilter.py b/Allura/allura/lib/spam/akismetfilter.py
index 25cc82c..7020632 100644
--- a/Allura/allura/lib/spam/akismetfilter.py
+++ b/Allura/allura/lib/spam/akismetfilter.py
@@ -23,7 +23,11 @@ from pylons import tmpl_context as c
 from allura.lib import helpers as h
 from allura.lib.spam import SpamFilter
 
-import akismet
+try:
+    import akismet
+    AKISMET_AVAILABLE = True
+except ImportError:
+    AKISMET_AVAILABLE = False
 
 
 log = logging.getLogger(__name__)
@@ -44,6 +48,8 @@ class AkismetSpamFilter(SpamFilter):
         spam.key = <your Akismet key here>
     """
     def __init__(self, config):
+        if not AKISMET_AVAILABLE:
+            raise ImportError('akismet not available')
         self.service = akismet.Akismet(config.get('spam.key'), config.get('base_url'))
         self.service.verify_key()
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/Allura/allura/lib/spam/mollomfilter.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/spam/mollomfilter.py b/Allura/allura/lib/spam/mollomfilter.py
index e0b2922..b00f978 100644
--- a/Allura/allura/lib/spam/mollomfilter.py
+++ b/Allura/allura/lib/spam/mollomfilter.py
@@ -23,7 +23,11 @@ from pylons import tmpl_context as c
 from allura.lib import helpers as h
 from allura.lib.spam import SpamFilter
 
-import Mollom
+try:
+    import Mollom
+    MOLLOM_AVAILABLE = True
+except ImportError:
+    MOLLOM_AVAILABLE = False
 
 
 log = logging.getLogger(__name__)
@@ -45,6 +49,8 @@ class MollomSpamFilter(SpamFilter):
         spam.private_key = <your Mollom private key here>
     """
     def __init__(self, config):
+        if not MOLLOM_AVAILABLE:
+            raise ImportError('Mollom not available')
         self.service = Mollom.MollomAPI(
             publicKey=config.get('spam.public_key'),
             privateKey=config.get('spam.private_key'))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/Allura/allura/tests/unit/spam/test_akismet.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/spam/test_akismet.py b/Allura/allura/tests/unit/spam/test_akismet.py
index e49e46b..571eb92 100644
--- a/Allura/allura/tests/unit/spam/test_akismet.py
+++ b/Allura/allura/tests/unit/spam/test_akismet.py
@@ -22,13 +22,10 @@ import mock
 import unittest
 import urllib
 
-try:
-    from allura.lib.spam.akismetfilter import AkismetSpamFilter
-except ImportError:
-    AkismetSpamFilter = None
+from allura.lib.spam.akismetfilter import AKISMET_AVAILABLE, AkismetSpamFilter
 
 
-@unittest.skipIf(AkismetSpamFilter is None, "Can't import AkismetSpamFilter")
+@unittest.skipIf(not AKISMET_AVAILABLE, "Akismet not available")
 class TestAkismet(unittest.TestCase):
     @mock.patch('allura.lib.spam.akismetfilter.akismet')
     def setUp(self, akismet_lib):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/Allura/allura/tests/unit/spam/test_mollom.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/spam/test_mollom.py b/Allura/allura/tests/unit/spam/test_mollom.py
index e1ee1fe..ac7441d 100644
--- a/Allura/allura/tests/unit/spam/test_mollom.py
+++ b/Allura/allura/tests/unit/spam/test_mollom.py
@@ -22,13 +22,11 @@ import mock
 import unittest
 import urllib
 
-try:
-    from allura.lib.spam.mollomfilter import MollomSpamFilter
-except ImportError:
-    MollomSpamFilter = None
 
+from allura.lib.spam.mollomfilter import MOLLOM_AVAILABLE, MollomSpamFilter
 
-@unittest.skipIf(MollomSpamFilter is None, "Can't import MollomSpamFilter")
+
+@unittest.skipIf(not MOLLOM_AVAILABLE, "Mollom not available")
 class TestMollom(unittest.TestCase):
     @mock.patch('allura.lib.spam.mollomfilter.Mollom')
     def setUp(self, mollom_lib):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/Allura/setup.py
----------------------------------------------------------------------
diff --git a/Allura/setup.py b/Allura/setup.py
index 5866792..983cff0 100644
--- a/Allura/setup.py
+++ b/Allura/setup.py
@@ -123,8 +123,8 @@ setup(
     allura = allura.lib.plugin:ThemeProvider
 
     [allura.spam]
-    #akismet = allura.lib.spam.akismetfilter:AkismetSpamFilter
-    #mollom = allura.lib.spam.mollomfilter:MollomSpamFilter
+    akismet = allura.lib.spam.akismetfilter:AkismetSpamFilter
+    mollom = allura.lib.spam.mollomfilter:MollomSpamFilter
 
     [paste.paster_command]
     taskd = allura.command.taskd:TaskdCommand

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/79642a38/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 2714786..a506fa4 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -17,6 +17,7 @@ sqlalchemy-migrate==0.7.1
 wsgipreload==1.2
 pyzmq==2.1.7
 html2text==3.200.3dev-20121112
+pymollom==0.1
 
 # use version built from https://github.com/johnsca/GitPython/commits/tv/6000
 # for unmerged fixes for [#5411], [#6000], and [#6078]


Mime
View raw message