From 6dccc13c780dfbdae536a3d35795e70e0073dc43 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 19 Nov 2014 11:58:55 -0500 Subject: [PATCH 1/3] Extract priorities from redmine responses appropriately. --- bugwarrior/services/redmine.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bugwarrior/services/redmine.py b/bugwarrior/services/redmine.py index 076e1c9ce..91f616fa8 100644 --- a/bugwarrior/services/redmine.py +++ b/bugwarrior/services/redmine.py @@ -55,6 +55,14 @@ class RedMineIssue(Issue): } UNIQUE_KEY = (URL, ) + PRIORITY_MAP = { + 0: 'L', + 1: 'L', + 2: 'M', + 3: 'H', + 4: 'H', + } + def to_taskwarrior(self): return { 'project': self.get_project_name(), @@ -65,6 +73,12 @@ def to_taskwarrior(self): self.ID: self.record['id'] } + def get_priority(self): + return self.PRIORITY_MAP.get( + self.record.get('priority', {}).get('id'), + self.origin['default_priority'] + ) + def get_issue_url(self): return ( self.origin['url'] + "/issues/" + six.text_type(self.record["id"]) From 89b0195fcbd164139e3344728a448c749202041b Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 19 Nov 2014 12:16:36 -0500 Subject: [PATCH 2/3] Use priority Name instead of id. --- bugwarrior/services/redmine.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bugwarrior/services/redmine.py b/bugwarrior/services/redmine.py index 91f616fa8..38095729f 100644 --- a/bugwarrior/services/redmine.py +++ b/bugwarrior/services/redmine.py @@ -56,11 +56,11 @@ class RedMineIssue(Issue): UNIQUE_KEY = (URL, ) PRIORITY_MAP = { - 0: 'L', - 1: 'L', - 2: 'M', - 3: 'H', - 4: 'H', + 'Low': 'L', + 'Normal': 'M', + 'High': 'H', + 'Urgent': 'H', + 'Immediate': 'H', } def to_taskwarrior(self): @@ -75,7 +75,7 @@ def to_taskwarrior(self): def get_priority(self): return self.PRIORITY_MAP.get( - self.record.get('priority', {}).get('id'), + self.record.get('priority', {}).get('Name'), self.origin['default_priority'] ) From 4a39602563285d7d1a37e6126c5279df3e303ba7 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Wed, 19 Nov 2014 12:17:09 -0500 Subject: [PATCH 3/3] Add a test for new redmine behavior and fix another bug. --- bugwarrior/services/redmine.py | 2 +- tests/test_redmine.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/bugwarrior/services/redmine.py b/bugwarrior/services/redmine.py index 38095729f..ef06afa90 100644 --- a/bugwarrior/services/redmine.py +++ b/bugwarrior/services/redmine.py @@ -92,7 +92,7 @@ def get_project_name(self): def get_default_description(self): return self.build_default_description( title=self.record['subject'], - url=self.get_processed_url(self.record['url']), + url=self.get_processed_url(self.get_issue_url()), number=self.record['id'], cls='issue', ) diff --git a/tests/test_redmine.py b/tests/test_redmine.py index eb71e6af5..b39d0b8f4 100644 --- a/tests/test_redmine.py +++ b/tests/test_redmine.py @@ -18,11 +18,36 @@ def setUp(self): def test_to_taskwarrior(self): arbitrary_url = 'http://lkjlj.com' arbitrary_issue = { - 'project': { - 'name': 'Something', + "assigned_to": { + "id": 35546, + "name": "Adam Coddington" }, - 'subject': 'The Subject', - 'id': 'The ID', + "author": { + "id": 35546, + "name": "Adam Coddington" + }, + "created_on": "2014-11-19T16:40:29Z", + "description": "This is a test issue.", + "done_ratio": 0, + "id": 363901, + "priority": { + "id": 4, + "name": "Normal" + }, + "project": { + "id": 27375, + "name": "Bugwarrior" + }, + "status": { + "id": 1, + "name": "New" + }, + "subject": "Biscuits", + "tracker": { + "id": 4, + "name": "Task" + }, + "updated_on": "2014-11-19T16:40:29Z" } issue = self.service.get_issue_for_record(arbitrary_issue)