allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: Allow spam checks where artifact=None; text fixes; for [ca8b596]
Date Thu, 26 Jan 2017 14:12:43 GMT
Repository: allura
Updated Branches:
  refs/heads/master 9b0106523 -> d6ed1a9c9


Allow spam checks where artifact=None; text fixes; for [ca8b596]


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

Branch: refs/heads/master
Commit: d6ed1a9c910ef42cb2465f645a85b6eb74e0f454
Parents: 9b01065
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Jan 12 13:12:34 2017 -0500
Committer: root <root@sft-box-9.v32.ch3.sourceforge.com>
Committed: Thu Jan 26 14:12:16 2017 +0000

----------------------------------------------------------------------
 Allura/allura/lib/spam/__init__.py            |  4 ++--
 Allura/allura/tests/unit/spam/test_akismet.py | 11 +++++++++--
 Allura/allura/tests/unit/spam/test_mollom.py  |  6 +++++-
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d6ed1a9c/Allura/allura/lib/spam/__init__.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/spam/__init__.py b/Allura/allura/lib/spam/__init__.py
index 8e68c5f..a4405e3 100644
--- a/Allura/allura/lib/spam/__init__.py
+++ b/Allura/allura/lib/spam/__init__.py
@@ -45,8 +45,8 @@ class SpamFilter(object):
         filter_name = self.__class__.__name__.replace('SpamFilter', '').lower()
         log.info("spam=%s (%s): %s" % (str(result), filter_name, artifact.url() if artifact
else ''))
         r = SpamCheckResult(
-            ref=artifact.ref,
-            project_id=artifact.project_id,
+            ref=artifact.ref if artifact else None,
+            project_id=artifact.project_id if artifact else None,
             user=user,
             result=result,
         )

http://git-wip-us.apache.org/repos/asf/allura/blob/d6ed1a9c/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 1435c35..17e6b51 100644
--- a/Allura/allura/tests/unit/spam/test_akismet.py
+++ b/Allura/allura/tests/unit/spam/test_akismet.py
@@ -22,6 +22,8 @@ import mock
 import unittest
 import urllib
 
+from bson import ObjectId
+
 from allura.lib.spam.akismetfilter import AKISMET_AVAILABLE, AkismetSpamFilter
 
 
@@ -37,9 +39,14 @@ class TestAkismet(unittest.TestCase):
             # akismet can be successfully urlencoded
             urllib.urlencode(kw.get('data', {}))
         self.akismet.service.comment_check = mock.Mock(side_effect=side_effect)
-        self.fake_artifact = mock.Mock(**{'main_url.return_value': 'artifact url'})
+        self.fake_artifact = mock.Mock(**{
+            'main_url.return_value': 'artifact url',
+            'project_id': ObjectId(),
+            'ref': None,
+        })
         self.fake_user = mock.Mock(display_name=u'Søme User',
-                                   email_addresses=['user@domain'])
+                                   email_addresses=['user@domain'],
+                                   _id=ObjectId())
         self.fake_headers = dict(
             USER_AGENT='some browser',
             REFERER='some url')

http://git-wip-us.apache.org/repos/asf/allura/blob/d6ed1a9c/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 cac2ab8..8a871f8 100644
--- a/Allura/allura/tests/unit/spam/test_mollom.py
+++ b/Allura/allura/tests/unit/spam/test_mollom.py
@@ -22,6 +22,7 @@ import mock
 import unittest
 import urllib
 
+from bson import ObjectId
 
 from allura.lib.spam.mollomfilter import MOLLOM_AVAILABLE, MollomSpamFilter
 
@@ -42,7 +43,8 @@ class TestMollom(unittest.TestCase):
                                                      return_value=dict(spam=2))
         self.fake_artifact = mock.Mock(**{'url.return_value': 'artifact url'})
         self.fake_user = mock.Mock(display_name=u'Søme User',
-                                   email_addresses=['user@domain'])
+                                   email_addresses=['user@domain'],
+                                   _id=ObjectId())
         self.fake_headers = dict(
             USER_AGENT='some browser',
             REFERER='some url')
@@ -52,6 +54,8 @@ class TestMollom(unittest.TestCase):
             authorIP='some ip')
         self.artifact = mock.Mock()
         self.artifact.spam_check_id = 'test_id'
+        self.artifact.project_id = ObjectId()
+        self.artifact.ref = None
 
     @mock.patch('allura.lib.spam.mollomfilter.c')
     @mock.patch('allura.lib.spam.mollomfilter.request')


Mime
View raw message