incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [07/50] git commit: [#6608] Trac ticket import cleanups
Date Tue, 24 Sep 2013 17:07:46 GMT
[#6608] Trac ticket import cleanups

* Set default Trac open/closed statuses
* If a ticket urlopen call fails during import, let the import fail
  rather than trying to continue in an unknown state
* Add test for setting milestone status during import

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.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/ffb98428
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ffb98428
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ffb98428

Branch: refs/heads/cj/6422
Commit: ffb98428fbb18341a8d5f31c7d0c646cd6253992
Parents: 54c43fd
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Sep 17 19:32:06 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Sep 18 20:24:31 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/trac/tickets.py   |  4 ++-
 .../functional/data/milestone-tickets.json      | 31 ++++++++++++++++++
 .../tests/functional/test_import.py             | 33 ++++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ffb98428/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index 88ee769..9b222b9 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -120,6 +120,8 @@ class TracTicketImporter(ToolImporter):
                 'Tickets',
                 mount_point=mount_point,
                 mount_label=mount_label or 'Tickets',
+                open_status_names='new assigned accepted reopened',
+                closed_status_names='closed',
                 import_id={
                         'source': self.source,
                         'trac_url': trac_url,
@@ -135,7 +137,7 @@ class TracTicketImporter(ToolImporter):
                     expires=datetime.utcnow() + timedelta(minutes=60))
             session(api_ticket).flush(api_ticket)
             cli = AlluraImportApiClient(config['base_url'], api_ticket.api_key,
-                    api_ticket.secret_key, verbose=True)
+                    api_ticket.secret_key, verbose=True, retry=False)
             import_tracker(cli, project.shortname, mount_point,
                     {'user_map': json.loads(user_map) if user_map else {}},
                     export_string, validate=False)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ffb98428/ForgeTracker/forgetracker/tests/functional/data/milestone-tickets.json
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/data/milestone-tickets.json b/ForgeTracker/forgetracker/tests/functional/data/milestone-tickets.json
new file mode 100644
index 0000000..1961b22
--- /dev/null
+++ b/ForgeTracker/forgetracker/tests/functional/data/milestone-tickets.json
@@ -0,0 +1,31 @@
+{
+  "class": "PROJECT",
+  "trackers": {
+    "default": {
+      "artifacts": [
+        {
+          "class": "ARTIFACT",
+          "date": "2009-04-13T08:49:13Z",
+          "date_updated": "2009-07-20T15:44:32Z",
+          "id": 1,
+          "milestone": "open_milestone",
+          "status": "open",
+          "description": "",
+          "submitter": "",
+          "summary": "Ticket 1"
+        },
+        {
+          "class": "ARTIFACT",
+          "date": "2009-04-13T08:49:13Z",
+          "date_updated": "2009-07-20T15:44:32Z",
+          "id": 2,
+          "milestone": "closed_milestone",
+          "status": "closed",
+          "description": "",
+          "submitter": "",
+          "summary": "Ticket 2"
+        }
+      ]
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ffb98428/ForgeTracker/forgetracker/tests/functional/test_import.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_import.py b/ForgeTracker/forgetracker/tests/functional/test_import.py
index 8192115..5b1f5a3 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_import.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_import.py
@@ -27,11 +27,13 @@ from pylons import app_globals as g
 from pylons import tmpl_context as c
 
 from allura import model as M
+from allura.lib import helpers as h
 from alluratest.controller import TestRestApiBase
 from allura.tests import decorators as td
 from forgetracker import model as TM
 from forgetracker.import_support import ImportSupport
 
+
 class TestImportController(TestRestApiBase):
 
     def new_ticket(self, mount_point='/bugs/', **kw):
@@ -169,6 +171,37 @@ class TestImportController(TestRestApiBase):
         assert ticket_json['summary'] in r
 
     @td.with_tracker
+    def test_milestone_status(self):
+        """When importing, if all tickets in a milestone are closed, the
+        milestone itself should also be closed.
+
+        """
+        here_dir = os.path.dirname(__file__)
+        api_ticket = M.ApiTicket(user_id=self.user._id, capabilities={'import': ['Projects','test']},
+                                 expires=datetime.utcnow() + timedelta(days=1))
+        ming.orm.session(api_ticket).flush()
+        self.set_api_token(api_ticket)
+
+        doc_text = open(here_dir + '/data/milestone-tickets.json').read()
+        self.api_post('/rest/p/test/bugs/perform_import', doc=doc_text,
+            options='{"user_map": {"hinojosa4": "test-admin", "ma_boehm": "test-user"}}')
+
+        ming.orm.ThreadLocalORMSession.flush_all()
+        M.MonQTask.run_ready()
+        ming.orm.ThreadLocalORMSession.flush_all()
+
+        with h.push_context('test', mount_point='bugs', neighborhood='Projects'):
+            for milestone_fld in c.app.globals.milestone_fields:
+                milestone_names = [ms['name'] for ms in milestone_fld['milestones']]
+                assert 'open_milestone' in milestone_names, milestone_names
+                assert 'closed_milestone' in milestone_names, milestone_names
+                for milestone in milestone_fld['milestones']:
+                    if milestone['name'] == 'open_milestone':
+                        assert milestone['complete'] == False
+                    if milestone['name'] == 'closed_milestone':
+                        assert milestone['complete'] == True
+
+    @td.with_tracker
     def test_link_processing(self):
         import_support = ImportSupport()
         result = import_support.link_processing('''test link [[2496]](http://testlink.com)


Mime
View raw message