incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [17/22] git commit: [#6464] Convert stars to anonymous up-votes in GC tracker importer
Date Tue, 20 Aug 2013 17:45:47 GMT
[#6464] Convert stars to anonymous up-votes in GC tracker importer

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

Branch: refs/heads/cj/6464
Commit: 4dc7f20d9dc9f7d038055ee4776e182d4429c4c9
Parents: 511e57d
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Aug 19 16:54:39 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Aug 20 17:34:14 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/google/__init__.py              | 7 +++++++
 ForgeImporters/forgeimporters/google/tracker.py               | 1 +
 .../forgeimporters/tests/google/functional/test_tracker.py    | 1 +
 ForgeImporters/forgeimporters/tests/google/test_extractor.py  | 1 +
 4 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4dc7f20d/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index fbf3eb0..1d570ea 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -226,6 +226,13 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
         else:
             return []
 
+    def get_issue_stars(self):
+        stars_re = re.compile(r'(\d+) (person|people) starred this issue')
+        stars = self.page.find(id='issueheader').find(text=stars_re)
+        if stars:
+            return int(stars_re.search(stars).group(1))
+        return 0
+
     def iter_comments(self):
         for comment in self.page.findAll('div', 'issuecomment'):
             yield Comment(comment)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4dc7f20d/ForgeImporters/forgeimporters/google/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tracker.py b/ForgeImporters/forgeimporters/google/tracker.py
index 3d9843c..1b888d9 100644
--- a/ForgeImporters/forgeimporters/google/tracker.py
+++ b/ForgeImporters/forgeimporters/google/tracker.py
@@ -84,6 +84,7 @@ class GoogleCodeTrackerImporter(ToolImporter):
         ticket.status = issue.get_issue_status()
         ticket.created_date = datetime.strptime(issue.get_issue_created_date(), '%c')
         ticket.mod_date = datetime.strptime(issue.get_issue_mod_date(), '%c')
+        ticket.votes_up = issue.get_issue_stars()
         owner = issue.get_issue_owner()
         if owner:
             owner_line = '*Originally owned by:* {owner}\n'.format(owner=owner)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4dc7f20d/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 80a8747..52eb50f 100644
--- a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
@@ -114,6 +114,7 @@ class TestGCTrackerImporter(TestCase):
                 '_milestone': 'Release1.0'
             })
         self.assertEqual(ticket.labels, ['Performance', 'Security'])
+        self.assertEqual(ticket.votes_up, 1)
 
     @skipif(module_not_available('html2text'))
     def test_html2text_escaping(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4dc7f20d/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 e208e8d..e196037 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
@@ -176,6 +176,7 @@ class TestGoogleCodeProjectExtractor(TestCase):
                 'That\'s all'
             )
         self.assertEqual(gpe.get_issue_created_date(), 'Thu Aug  8 15:33:52 2013')
+        self.assertEqual(gpe.get_issue_stars(), 1)
 
     def test_get_issue_mod_date(self):
         test_issue = open(pkg_resources.resource_filename('forgeimporters', 'tests/data/google/test-issue.html')).read()


Mime
View raw message