summaryrefslogtreecommitdiffstats
path: root/patchwork
diff options
context:
space:
mode:
Diffstat (limited to 'patchwork')
-rwxr-xr-xpatchwork/bin/parsemail.py54
-rw-r--r--patchwork/settings/base.py2
-rw-r--r--patchwork/settings/dev.py3
-rw-r--r--patchwork/tests/__init__.py35
-rw-r--r--patchwork/tests/test_patchparser.py40
5 files changed, 45 insertions, 89 deletions
diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
index 19e6e57..5cb0b50 100755
--- a/patchwork/bin/parsemail.py
+++ b/patchwork/bin/parsemail.py
@@ -267,23 +267,8 @@ def find_patch_for_comment(project, mail):
split_re = re.compile('[,\s]+')
def split_prefixes(prefix):
- """ Turn a prefix string into a list of prefix tokens
-
- >>> split_prefixes('PATCH')
- ['PATCH']
- >>> split_prefixes('PATCH,RFC')
- ['PATCH', 'RFC']
- >>> split_prefixes('')
- []
- >>> split_prefixes('PATCH,')
- ['PATCH']
- >>> split_prefixes('PATCH ')
- ['PATCH']
- >>> split_prefixes('PATCH,RFC')
- ['PATCH', 'RFC']
- >>> split_prefixes('PATCH 1/2')
- ['PATCH', '1/2']
- """
+ """ Turn a prefix string into a list of prefix tokens """
+
matches = split_re.split(prefix)
return [ s for s in matches if s != '' ]
@@ -296,39 +281,8 @@ def clean_subject(subject, drop_prefixes = None):
Removes Re: and Fwd: strings, as well as [PATCH]-style prefixes. By
default, only [PATCH] is removed, and we keep any other bracketed data
in the subject. If drop_prefixes is provided, remove those too,
- comparing case-insensitively.
-
- >>> clean_subject('meep')
- 'meep'
- >>> clean_subject('Re: meep')
- 'meep'
- >>> clean_subject('[PATCH] meep')
- 'meep'
- >>> clean_subject('[PATCH] meep \\n meep')
- 'meep meep'
- >>> clean_subject('[PATCH RFC] meep')
- '[RFC] meep'
- >>> clean_subject('[PATCH,RFC] meep')
- '[RFC] meep'
- >>> clean_subject('[PATCH,1/2] meep')
- '[1/2] meep'
- >>> clean_subject('[PATCH RFC 1/2] meep')
- '[RFC,1/2] meep'
- >>> clean_subject('[PATCH] [RFC] meep')
- '[RFC] meep'
- >>> clean_subject('[PATCH] [RFC,1/2] meep')
- '[RFC,1/2] meep'
- >>> clean_subject('[PATCH] [RFC] [1/2] meep')
- '[RFC,1/2] meep'
- >>> clean_subject('[PATCH] rewrite [a-z] regexes')
- 'rewrite [a-z] regexes'
- >>> clean_subject('[PATCH] [RFC] rewrite [a-z] regexes')
- '[RFC] rewrite [a-z] regexes'
- >>> clean_subject('[foo] [bar] meep', ['foo'])
- '[bar] meep'
- >>> clean_subject('[FOO] [bar] meep', ['foo'])
- '[bar] meep'
- """
+ comparing case-insensitively."""
+
subject = clean_header(subject)
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 9b52989..5b40bcb 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -113,3 +113,5 @@ COMPAT_REDIR = True
# the scheme based on current access. This is useful if SSL protocol
# is terminated upstream of the server (e.g. at the load balancer)
FORCE_HTTPS_LINKS = False
+
+TEST_RUNNER = 'django.test.runner.DiscoverRunner'
diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py
index 6e373cc..3f2355d 100644
--- a/patchwork/settings/dev.py
+++ b/patchwork/settings/dev.py
@@ -42,9 +42,6 @@ DATABASES = {
},
}
-if django.VERSION >= (1, 7):
- TEST_RUNNER = 'django.test.runner.DiscoverRunner'
-
#
# Patchwork settings
#
diff --git a/patchwork/tests/__init__.py b/patchwork/tests/__init__.py
index 662386a..e69de29 100644
--- a/patchwork/tests/__init__.py
+++ b/patchwork/tests/__init__.py
@@ -1,35 +0,0 @@
-# Patchwork - automated patch tracking system
-# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
-#
-# This file is part of the Patchwork package.
-#
-# Patchwork 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 2 of the License, or
-# (at your option) any later version.
-#
-# Patchwork 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 Patchwork; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from patchwork.tests.test_patchparser import *
-from patchwork.tests.test_tags import *
-from patchwork.tests.test_encodings import *
-from patchwork.tests.test_bundles import *
-from patchwork.tests.test_mboxviews import *
-from patchwork.tests.test_updates import *
-from patchwork.tests.test_filters import *
-from patchwork.tests.test_confirm import *
-from patchwork.tests.test_registration import *
-from patchwork.tests.test_user import *
-from patchwork.tests.test_mail_settings import *
-from patchwork.tests.test_notifications import *
-from patchwork.tests.test_list import *
-from patchwork.tests.test_person import *
-from patchwork.tests.test_expiry import *
-from patchwork.tests.test_xmlrpc import *
diff --git a/patchwork/tests/test_patchparser.py b/patchwork/tests/test_patchparser.py
index 5eefeb5..da2b07a 100644
--- a/patchwork/tests/test_patchparser.py
+++ b/patchwork/tests/test_patchparser.py
@@ -37,7 +37,7 @@ class PatchTest(TestCase):
project = defaults.project
from patchwork.bin.parsemail import find_content, find_author, find_project, \
- parse_mail
+ parse_mail, split_prefixes, clean_subject
class InlinePatchTest(PatchTest):
patch_filename = '0001-add-line.patch'
@@ -579,3 +579,41 @@ class ParseInitialTagsTest(PatchTest):
tag__name='Reviewed-by').count, 1)
self.assertEquals(patch.patchtag_set.get(
tag__name='Tested-by').count, 1)
+
+class PrefixTest(TestCase):
+
+ def testSplitPrefixes(self):
+ self.assertEquals(split_prefixes('PATCH'), ['PATCH'])
+ self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+ self.assertEquals(split_prefixes(''), [])
+ self.assertEquals(split_prefixes('PATCH,'), ['PATCH'])
+ self.assertEquals(split_prefixes('PATCH '), ['PATCH'])
+ self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+ self.assertEquals(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
+
+class SubjectTest(TestCase):
+
+ def testCleanSubject(self):
+ self.assertEquals(clean_subject('meep'), 'meep')
+ self.assertEquals(clean_subject('Re: meep'), 'meep')
+ self.assertEquals(clean_subject('[PATCH] meep'), 'meep')
+ self.assertEquals(clean_subject('[PATCH] meep \n meep'), 'meep meep')
+ self.assertEquals(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
+ self.assertEquals(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
+ self.assertEquals(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
+ self.assertEquals(clean_subject('[PATCH RFC 1/2] meep'),
+ '[RFC,1/2] meep')
+ self.assertEquals(clean_subject('[PATCH] [RFC] meep'),
+ '[RFC] meep')
+ self.assertEquals(clean_subject('[PATCH] [RFC,1/2] meep'),
+ '[RFC,1/2] meep')
+ self.assertEquals(clean_subject('[PATCH] [RFC] [1/2] meep'),
+ '[RFC,1/2] meep')
+ self.assertEquals(clean_subject('[PATCH] rewrite [a-z] regexes'),
+ 'rewrite [a-z] regexes')
+ self.assertEquals(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
+ '[RFC] rewrite [a-z] regexes')
+ self.assertEquals(clean_subject('[foo] [bar] meep', ['foo']),
+ '[bar] meep')
+ self.assertEquals(clean_subject('[FOO] [bar] meep', ['foo']),
+ '[bar] meep')