incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [18/26] git commit: [#6464] Sort and close milestones on GC Tracker importer
Date Wed, 21 Aug 2013 17:35:01 GMT
[#6464] Sort and close milestones on 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/ead70f50
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ead70f50
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ead70f50

Branch: refs/heads/cj/6580
Commit: ead70f5071cfbc4c995eacd342199a0ea9e51720
Parents: 1e93964
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Aug 20 18:14:16 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Aug 20 18:14:16 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/google/tracker.py            | 7 +++++--
 ForgeImporters/forgeimporters/tests/google/test_tracker.py | 8 +++++---
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ead70f50/ForgeImporters/forgeimporters/google/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tracker.py b/ForgeImporters/forgeimporters/google/tracker.py
index 9f99348..51391a2 100644
--- a/ForgeImporters/forgeimporters/google/tracker.py
+++ b/ForgeImporters/forgeimporters/google/tracker.py
@@ -49,6 +49,7 @@ class GoogleCodeTrackerImporter(ToolImporter):
         app.globals.open_status_names = 'New Accepted Started'
         app.globals.closed_status_names = 'Fixed Verified Invalid Duplicate WontFix Done'
         ThreadLocalORMSession.flush_all()
+        self.open_milestones = set()
         self.custom_fields = {}
         try:
             M.session.artifact_orm_session._get().skip_mod_date = True
@@ -110,6 +111,8 @@ class GoogleCodeTrackerImporter(ToolImporter):
                 cf = self.custom_field(name)
                 cf['options'].add(value)
                 custom_fields[cf['name']].add(value)
+                if cf['name'] == '_milestone' and ticket.status in c.app.globals.open_status_names:
+                    self.open_milestones.add(value)
             else:
                 labels.add(label)
         ticket.labels = list(labels)
@@ -131,8 +134,8 @@ class GoogleCodeTrackerImporter(ToolImporter):
                 field['milestones'] = [{
                         'name': milestone,
                         'due_date': None,
-                        'complete': False,
-                    } for milestone in field['options']]
+                        'complete': milestone not in self.open_milestones,
+                    } for milestone in sorted(field['options'])]
                 field['options'] = ''
             elif field['type'] == 'select':
                 field['options'] = ' '.join(field['options'])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ead70f50/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 01d9f8e..05c4c6e 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
@@ -192,6 +192,7 @@ class TestTrackerImporter(TestCase):
     @mock.patch.object(tracker, 'c')
     def test_postprocess_custom_fields(self, c):
         importer = tracker.GoogleCodeTrackerImporter()
+        importer.open_milestones = set(['m2', 'm3'])
         importer.custom_fields = {
                 'Foo': {
                     'name': '_foo',
@@ -201,7 +202,7 @@ class TestTrackerImporter(TestCase):
                 'Milestone': {
                     'name': '_milestone',
                     'type': 'milestone',
-                    'options': set(['foo', 'bar']),
+                    'options': set(['m3', 'm1', 'm2']),
                 },
                 'Priority': {
                     'name': '_priority',
@@ -221,8 +222,9 @@ class TestTrackerImporter(TestCase):
                     'type': 'milestone',
                     'options': '',
                     'milestones': [
-                        {'name': 'foo', 'due_date': None, 'complete': False},
-                        {'name': 'bar', 'due_date': None, 'complete': False},
+                        {'name': 'm1', 'due_date': None, 'complete': True},
+                        {'name': 'm2', 'due_date': None, 'complete': False},
+                        {'name': 'm3', 'due_date': None, 'complete': False},
                     ],
                 },
                 {


Mime
View raw message