This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 563021744 move akismet imports, in case the package is not installed
563021744 is described below
commit 5630217446fd9fec64f53f4f86cc8a6cdeff791b
Author: Dave Brondsema <[email protected]>
AuthorDate: Tue May 21 12:45:32 2024 -0400
move akismet imports, in case the package is not installed
---
Allura/allura/lib/spam/akismetfilter.py | 3 +--
Allura/allura/tests/unit/spam/test_akismet.py | 9 +++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Allura/allura/lib/spam/akismetfilter.py
b/Allura/allura/lib/spam/akismetfilter.py
index 9f221992f..34caaae38 100644
--- a/Allura/allura/lib/spam/akismetfilter.py
+++ b/Allura/allura/lib/spam/akismetfilter.py
@@ -17,7 +17,6 @@
import logging
-from akismet import CheckResponse
from tg import request
from tg import tmpl_context as c
@@ -113,7 +112,7 @@ class AkismetSpamFilter(SpamFilter):
content_type=content_type,
request=request,
))
- spam = res != CheckResponse.HAM
+ spam = res != akismet.CheckResponse.HAM
self.record_result(spam, artifact, user)
return res
diff --git a/Allura/allura/tests/unit/spam/test_akismet.py
b/Allura/allura/tests/unit/spam/test_akismet.py
index 20a205fa8..ca56f67d9 100644
--- a/Allura/allura/tests/unit/spam/test_akismet.py
+++ b/Allura/allura/tests/unit/spam/test_akismet.py
@@ -17,23 +17,24 @@
import mock
-import unittest
+import pytest
import six.moves.urllib.request
import six.moves.urllib.parse
import six.moves.urllib.error
from datetime import datetime
-from akismet import CheckResponse
from bson import ObjectId
from allura.lib.spam.akismetfilter import AKISMET_AVAILABLE, AkismetSpamFilter
[email protected](not AKISMET_AVAILABLE, "Akismet not available")
-class TestAkismet(unittest.TestCase):
[email protected](not AKISMET_AVAILABLE, reason="Akismet not available")
+class TestAkismet:
@mock.patch('allura.lib.spam.akismetfilter.akismet')
def setup_method(self, method, akismet_lib):
+ from akismet import CheckResponse
+
self.akismet = AkismetSpamFilter({'spam.key': 'example', 'base_url':
'http://localhost/'})
def side_effect(*args, **kw):