allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [15/16] git commit: [#6464] Fixed issues from rebase
Date Fri, 16 Aug 2013 22:21:51 GMT
[#6464] Fixed issues from rebase

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/123cb154
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/123cb154
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/123cb154

Branch: refs/heads/cj/6464
Commit: 123cb15447f9159f8bf3db38d13785e8f031049d
Parents: 3eab85b
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Aug 14 16:26:53 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Aug 16 22:21:00 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/google/__init__.py        |  7 ++-----
 ForgeImporters/forgeimporters/google/tests/test_code.py |  4 +++-
 .../forgeimporters/tests/google/test_extractor.py       | 12 +++++++++---
 .../forgeimporters/tests/google/test_tracker.py         |  4 +++-
 4 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/123cb154/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index 660853f..90319cd 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -79,7 +79,6 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
     DEFAULT_ICON = 'http://www.gstatic.com/codesite/ph/images/defaultlogo.png'
 
     def __init__(self, project_name, page_name=None, **kw):
-        self.url = self.PAGE_MAP[page_name].format(
         self.project_name = project_name
         self._page_cache = {}
         self.url = None
@@ -105,7 +104,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
         if self.url in self._page_cache:
             self.page = self._page_cache[self.url]
         else:
-            self.page = self._page_cache[page_name_or_url] = \
+            self.page = self._page_cache[self.url] = \
                     BeautifulSoup(self.urlopen(self.url))
         return self.page
 
@@ -116,9 +115,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
 
         """
         return self.PAGE_MAP[page_name].format(
-            project_name = urllib.quote(self.project_name),
-            **kw,
-        )
+            project_name = urllib.quote(self.project_name), **kw)
 
     def get_short_description(self, project):
         page = self.get_page('project_info')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/123cb154/ForgeImporters/forgeimporters/google/tests/test_code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tests/test_code.py b/ForgeImporters/forgeimporters/google/tests/test_code.py
index 13ec0c3..950246a 100644
--- a/ForgeImporters/forgeimporters/google/tests/test_code.py
+++ b/ForgeImporters/forgeimporters/google/tests/test_code.py
@@ -56,9 +56,10 @@ class TestGoogleRepoImporter(TestCase):
         project.get_tool_data.side_effect = lambda *args: gc_proj_name
         return project
 
+    @patch('forgeimporters.google.code.g')
     @patch('forgeimporters.google.code.GoogleCodeProjectExtractor')
     @patch('forgeimporters.google.code.get_repo_url')
-    def test_import_tool_happy_path(self, get_repo_url, gcpe):
+    def test_import_tool_happy_path(self, get_repo_url, gcpe, g):
         gcpe.return_value.get_repo_type.return_value = 'git'
         get_repo_url.return_value = 'http://remote/clone/url/'
         p = self._make_project(gc_proj_name='myproject')
@@ -70,6 +71,7 @@ class TestGoogleRepoImporter(TestCase):
                 mount_label='Code',
                 init_from_url='http://remote/clone/url/',
                 )
+        g.post_event.assert_called_once_with('project_updated')
 
 
 class TestGoogleRepoImportController(TestController, TestCase):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/123cb154/ForgeImporters/forgeimporters/tests/google/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_extractor.py b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
index bac1750..7a485d6 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
@@ -45,14 +45,20 @@ class TestGoogleCodeProjectExtractor(TestCase):
         self.assertEqual(extractor.page, self.soup.return_value)
 
     def test_get_page(self):
-        extractor = google.GoogleCodeProjectExtractor(self.project, 'my-project', 'project_info')
+        extractor = google.GoogleCodeProjectExtractor('my-project', 'project_info')
+        self.assertEqual(1, self.urlopen.call_count)
+        page = extractor.get_page('project_info')
         self.assertEqual(1, self.urlopen.call_count)
+        self.assertEqual(page, extractor._page_cache['http://code.google.com/p/my-project/'])
         page = extractor.get_page('project_info')
         self.assertEqual(1, self.urlopen.call_count)
-        self.assertEqual(page, extractor._page_cache['project_info'])
+        self.assertEqual(page, extractor._page_cache['http://code.google.com/p/my-project/'])
+        page = extractor.get_page('source_browse')
+        self.assertEqual(2, self.urlopen.call_count)
+        self.assertEqual(page, extractor._page_cache['http://code.google.com/p/my-project/source/browse/'])
 
     def test_get_page_url(self):
-        extractor = google.GoogleCodeProjectExtractor(self.project, 'my-project')
+        extractor = google.GoogleCodeProjectExtractor('my-project')
         self.assertEqual(extractor.get_page_url('project_info'),
                 'http://code.google.com/p/my-project/')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/123cb154/ForgeImporters/forgeimporters/tests/google/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
index 70ea3ad..15b8f33 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
@@ -24,13 +24,14 @@ from ...google import tracker
 
 
 class TestTrackerImporter(TestCase):
+    @mock.patch.object(tracker, 'g')
     @mock.patch.object(tracker, 'c')
     @mock.patch.object(tracker, 'ThreadLocalORMSession')
     @mock.patch.object(tracker, 'session')
     @mock.patch.object(tracker, 'M')
     @mock.patch.object(tracker, 'TM')
     @mock.patch.object(tracker, 'GoogleCodeProjectExtractor')
-    def test_import_tool(self, gpe, TM, M, session, tlos, c):
+    def test_import_tool(self, gpe, TM, M, session, tlos, c, g):
         importer = tracker.GoogleCodeTrackerImporter()
         importer.process_fields = mock.Mock()
         importer.process_labels = mock.Mock()
@@ -70,6 +71,7 @@ class TestTrackerImporter(TestCase):
                 mock.call(tickets[0]),
                 mock.call(tickets[1]),
             ])
+        g.post_event.assert_called_once_with('project_updated')
 
     def test_custom_fields(self):
         importer = tracker.GoogleCodeTrackerImporter()


Mime
View raw message