Skip to content

Commit

Permalink
Merge pull request #155 from ralphbean/feature/redmine-priorities
Browse files Browse the repository at this point in the history
Attempt to extract priorities from redmine responses appropriately.
  • Loading branch information
ralphbean committed Nov 20, 2014
2 parents 0f11061 + 4a39602 commit 2a8c1d8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
16 changes: 15 additions & 1 deletion bugwarrior/services/redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ class RedMineIssue(Issue):
}
UNIQUE_KEY = (URL, )

PRIORITY_MAP = {
'Low': 'L',
'Normal': 'M',
'High': 'H',
'Urgent': 'H',
'Immediate': 'H',
}

def to_taskwarrior(self):
return {
'project': self.get_project_name(),
Expand All @@ -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('Name'),
self.origin['default_priority']
)

def get_issue_url(self):
return (
self.origin['url'] + "/issues/" + six.text_type(self.record["id"])
Expand All @@ -78,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',
)
Expand Down
33 changes: 29 additions & 4 deletions tests/test_redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2a8c1d8

Please sign in to comment.