Skip to content

Commit

Permalink
Improve epics support (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed May 5, 2019
1 parent 73a2270 commit 8c52977
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions taiga/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def search(self, project, text=''):
search_result.wikipages = self.wikipages.parse_list(
result['wikipages']
)
search_result.epics = self.epics.parse_list(
result['epics']
)
return search_result

def auth(self, username, password):
Expand Down
16 changes: 14 additions & 2 deletions taiga/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class Epic(CustomAttributeResource, CommentableResource):
:param subject: subject of the :class:`TaskStatus`
:param tags: tags of the :class:`TaskStatus`
:param watchers: watchers of the :class:`TaskStatus`
:param version: version of the :class:`Epic`
"""

endpoint = 'epics'
Expand All @@ -304,7 +305,7 @@ class Epic(CustomAttributeResource, CommentableResource):
allowed_params = [
'assigned_to', 'blocked_note', 'description',
'is_blocked', 'is_closed', 'color', 'project',
'subject', 'tags', 'watchers'
'subject', 'tags', 'watchers', 'version'
]

def list_user_stories(self, **queryparams):
Expand Down Expand Up @@ -1107,7 +1108,8 @@ class Project(InstanceResource):
'severities': Severities,
'roles': Roles,
'points': Points,
'us_statuses': UserStoryStatuses
'us_statuses': UserStoryStatuses,
'milestones': Milestones
}

def get_item_by_ref(self, ref):
Expand Down Expand Up @@ -1856,6 +1858,7 @@ def __init__(self, *args, **kwargs):
self.task = HistoryTask(self.requester)
self.user_story = HistoryUserStory(self.requester)
self.wiki = HistoryWiki(self.requester)
self.epic = HistoryEpic(self.requester)


class HistoryEntity(object):
Expand Down Expand Up @@ -1916,6 +1919,15 @@ def __init__(self, *args, **kwargs):
self.entity = 'issue'


class HistoryEpic(HistoryEntity):
"""
HistoryEpic model
"""
def __init__(self, *args, **kwargs):
super(type(self), self).__init__(*args, **kwargs)
self.entity = 'epic'


class HistoryTask(HistoryEntity):
"""
HistoryTask model
Expand Down
16 changes: 16 additions & 0 deletions tests/resources/search_success.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,21 @@
"modified_date": "2015-01-01T09:29:53+0000",
"watchers": []
}
],
"epics":[
{
"id": 209,
"ref": 3,
"subject": "New Story",
"status": 138,
"assigned_to": null
},
{
"id": 210,
"ref": 4,
"subject": "New Story",
"status": 138,
"assigned_to": null
}
]
}
4 changes: 3 additions & 1 deletion tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mock import patch

from taiga import TaigaAPI
from taiga.models import Issue, Task, UserStory, WikiPage
from taiga.models import Epic, Issue, Task, UserStory, WikiPage

from .tools import MockResponse, create_mock_json

Expand All @@ -21,8 +21,10 @@ def test_single_user_parsing(self, mock_requestmaker_get):
self.assertEqual(len(search_result.user_stories), 1)
self.assertEqual(len(search_result.issues), 1)
self.assertEqual(len(search_result.wikipages), 1)
self.assertEqual(len(search_result.epics), 2)

self.assertTrue(isinstance(search_result.tasks[0], Task))
self.assertTrue(isinstance(search_result.issues[0], Issue))
self.assertTrue(isinstance(search_result.user_stories[0], UserStory))
self.assertTrue(isinstance(search_result.wikipages[0], WikiPage))
self.assertTrue(isinstance(search_result.epics[0], Epic))

0 comments on commit 8c52977

Please sign in to comment.