You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/08/21 19:34:54 UTC
[11/26] git commit: [#6464] Fixed issues from rebase
[#6464] Fixed issues from rebase
Signed-off-by: Cory Johns <cj...@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/5cd17091
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5cd17091
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5cd17091
Branch: refs/heads/cj/6580
Commit: 5cd17091ffaaaf4f20b89af9fc3a4915f5a7a1e2
Parents: a661fd5
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Aug 16 02:06:33 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Aug 20 17:34:14 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/helpers.py | 3 +++
Allura/allura/tests/test_helpers.py | 9 +++++----
ForgeImporters/forgeimporters/google/__init__.py | 4 ++--
.../tests/google/functional/test_tracker.py | 14 ++++++++------
4 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5cd17091/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 01586c2..39bf250 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -956,6 +956,9 @@ def plain2markdown(text, preserve_multiple_spaces=False, has_html_entities=False
if preserve_multiple_spaces:
text = text.replace('\t', ' ' * 4)
text = re_preserve_spaces.sub(' ', text)
+ else:
+ text = re_leading_spaces.sub('', text)
+ try:
# try to use html2text for most of the escaping
import html2text
html2text.BODY_WIDTH = 0
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5cd17091/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 03a530c..4a0b80d 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -292,17 +292,18 @@ M & Ms - doesn't get escaped
http://blah.com/?x=y&a=b - not escaped either
'''
- assert_equals(h.plain2markdown(text), expected)
+ dd.assert_equal(h.plain2markdown(text), expected)
- assert_equals(h.plain2markdown('a foo bar\n\n code here?', preserve_multiple_spaces=True),
+ dd.assert_equal(h.plain2markdown('a foo bar\n\n code here?', preserve_multiple_spaces=True),
'a foo bar\n\n code here?')
- assert_equals(h.plain2markdown('\ttab before (stuff)', preserve_multiple_spaces=True),
+ dd.assert_equal(h.plain2markdown('\ttab before (stuff)', preserve_multiple_spaces=True),
' tab before \(stuff\)')
- assert_equals(h.plain2markdown('\ttab before (stuff)', preserve_multiple_spaces=False),
+ dd.assert_equal(h.plain2markdown('\ttab before (stuff)', preserve_multiple_spaces=False),
'tab before \(stuff\)')
+
@td.without_module('html2text')
def test_plain2markdown():
"""Test plain2markdown using fallback regexp to escape markdown.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5cd17091/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index f60bc58..7234dc8 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -156,7 +156,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
@classmethod
def _get_issue_ids_page(cls, project_name, start):
url = cls.PAGE_MAP['issues_csv'].format(project_name=project_name, start=start)
- with closing(urllib2.urlopen(url)) as fp:
+ with closing(cls.urlopen(url)) as fp:
lines = fp.readlines()[1:] # skip CSV header
if not lines[-1].startswith('"'):
lines.pop() # skip "next page here" info footer
@@ -285,6 +285,6 @@ class Attachment(object):
@property
def file(self):
- fp_ish = urllib2.urlopen(self.url)
+ fp_ish = GoogleCodeProjectExtractor(None).urlopen(self.url)
fp = StringIO(fp_ish.read())
return fp
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5cd17091/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
index 7d67255..62c4453 100644
--- a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
@@ -29,15 +29,17 @@ from IPython.testing.decorators import module_not_available, skipif
from alluratest.controller import setup_basic_test
from allura.tests.decorators import without_module
from allura import model as M
+from allura.lib import helpers as h
from forgetracker import model as TM
-from .... import google
-from ....google import tracker
+from forgeimporters import base
+from forgeimporters import google
+from forgeimporters.google import tracker
class TestGCTrackerImporter(TestCase):
def _make_extractor(self, html):
- with mock.patch.object(google, 'urllib2') as urllib2:
- urllib2.urlopen.return_value = ''
+ with mock.patch.object(base.h, 'urlopen') as urlopen:
+ urlopen.return_value = ''
extractor = google.GoogleCodeProjectExtractor('my-project', 'project_info')
extractor.page = BeautifulSoup(html)
extractor.url = "http://test/issue/?id=1"
@@ -45,9 +47,9 @@ class TestGCTrackerImporter(TestCase):
def _make_ticket(self, issue):
self.assertIsNone(self.project.app_instance('test-issue'))
- with mock.patch.object(google, 'urllib2') as urllib2,\
+ with mock.patch.object(base.h, 'urlopen') as urlopen,\
mock.patch.object(google.tracker, 'GoogleCodeProjectExtractor') as GPE:
- urllib2.urlopen = lambda url: mock.Mock(read=lambda: url)
+ urlopen.side_effect = lambda req, **kw: mock.Mock(read=req.get_full_url)
GPE.iter_issues.return_value = [issue]
gti = google.tracker.GoogleCodeTrackerImporter()
gti.import_tool(self.project, self.user, 'test-issue-project', mount_point='test-issue')