Repository: nephila/python-taiga
Pull request #85 (2019-05-05 14:19:36)

Improve epics support
* Add support for HIstory and Search


Patch:
diff --git a/taiga/client.py b/taiga/client.py
index b339f24..e624863 100644
--- a/taiga/client.py
+++ b/taiga/client.py
@@ -99,6 +99,9 @@ class TaigaAPI:
         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):
diff --git a/taiga/models/models.py b/taiga/models/models.py
index f389253..a585a50 100644
--- a/taiga/models/models.py
+++ b/taiga/models/models.py
@@ -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'
@@ -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):
@@ -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):
@@ -1856,6 +1858,7 @@ class History(InstanceResource):
         self.task = HistoryTask(self.requester)
         self.user_story = HistoryUserStory(self.requester)
         self.wiki = HistoryWiki(self.requester)
+        self.epic = HistoryEpic(self.requester)
 
 
 class HistoryEntity(object):
@@ -1916,6 +1919,15 @@ class HistoryIssue(HistoryEntity):
         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


Test patch:
diff --git a/tests/resources/search_success.json b/tests/resources/search_success.json
index 474b598..a8a2b92 100644
--- a/tests/resources/search_success.json
+++ b/tests/resources/search_success.json
@@ -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
+        }
     ]
 }
diff --git a/tests/test_search.py b/tests/test_search.py
index 0052fa6..600daba 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -3,7 +3,7 @@ import unittest
 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
 
@@ -21,8 +21,10 @@ class TestSearch(unittest.TestCase):
         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))