Repository: nephila/python-taiga
Pull request #86 (2019-05-05 14:30:02)

Remove demo.py
`demo.py` is messy and not really useful

A better approach would be to provide a more usable sample scripts, but get rid of it for now


Patch:
diff --git a/.gitignore b/.gitignore
index f814033..54a2782 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,4 @@ cover
 /debian/.debhelper/
 /debian/files
 /debian/*build*
+demo.py
diff --git a/demo.py b/demo.py
deleted file mode 100644
index ce598dc..0000000
--- a/demo.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from taiga import TaigaAPI
-from taiga.exceptions import TaigaException
-
-api = TaigaAPI(
-    host='http://127.0.0.1:8000'
-)
-
-api.auth(
-    username='admin',
-    password='123123'
-)
-
-print(api.me())
-
-new_project = api.projects.create('TEST PROJECT', 'TESTING API')
-
-new_project.name = 'TEST PROJECT 3'
-new_project.update()
-
-print(new_project.members)
-
-for member in new_project.members:
-    print(member)
-
-jan_feb_milestone = new_project.add_milestone(
-    'New milestone jan feb', '2015-01-26', '2015-02-26'
-)
-
-userstory = new_project.add_user_story(
-    'New Story', description='Blablablabla',
-    milestone=jan_feb_milestone.id
-)
-userstory.attach('README.md')
-
-userstory.add_task(
-    'New Task 2',
-    new_project.task_statuses[0].id
-).attach('README.md')
-
-print(userstory.list_tasks())
-
-newissue = new_project.add_issue(
-    'New Issue',
-    new_project.priorities.get(name='High').id,
-    new_project.issue_statuses.get(name='New').id,
-    new_project.issue_types.get(name='Bug').id,
-    new_project.severities.get(name='Minor').id,
-    description='Bug #5'
-).attach('README.md')
-
-projects = api.projects.list()
-
-print(projects)
-
-stories = api.user_stories.list()
-
-print(stories)
-
-print(api.history.user_story.get(stories[0].id))
-
-try:
-    projects[0].star()
-except TaigaException:
-    projects[0].like()
-
-api.milestones.list()
-
-projects = api.projects.list()
-print(projects)
-
-another_new_project = projects.get(name='TEST PROJECT 3')
-
-print(another_new_project)
-
-users = api.users.list()
-
-print(users)
-
-print(api.search(projects.get(name='TEST PROJECT 3').id, 'New').user_stories[0].subject)
-
-print
-new_project.add_issue_attribute(
-    'Device', description='(iPad, iPod, iPhone, Desktop, etc.)'
-)
-
-print(new_project.roles)
-
-memberships = new_project.list_memberships()
-new_project.add_role('New role', permissions=["add_issue", "modify_issue"])
-
-new_project.add_membership('stagi.andrea@gmail.com', new_project.roles[0].id)
-for membership in memberships:
-    print(membership.role_name)
diff --git a/taiga/client.py b/taiga/client.py
index e624863..b339f24 100644
--- a/taiga/client.py
+++ b/taiga/client.py
@@ -99,9 +99,6 @@ 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 a585a50..f389253 100644
--- a/taiga/models/models.py
+++ b/taiga/models/models.py
@@ -295,7 +295,6 @@ 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'
@@ -305,7 +304,7 @@ class Epic(CustomAttributeResource, CommentableResource):
     allowed_params = [
         'assigned_to', 'blocked_note', 'description',
         'is_blocked', 'is_closed', 'color', 'project',
-        'subject', 'tags', 'watchers', 'version'
+        'subject', 'tags', 'watchers'
     ]
 
     def list_user_stories(self, **queryparams):
@@ -1108,8 +1107,7 @@ class Project(InstanceResource):
         'severities': Severities,
         'roles': Roles,
         'points': Points,
-        'us_statuses': UserStoryStatuses,
-        'milestones': Milestones
+        'us_statuses': UserStoryStatuses
     }
 
     def get_item_by_ref(self, ref):
@@ -1858,7 +1856,6 @@ 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):
@@ -1919,15 +1916,6 @@ 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 a8a2b92..474b598 100644
--- a/tests/resources/search_success.json
+++ b/tests/resources/search_success.json
@@ -131,21 +131,5 @@
             "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 600daba..0052fa6 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 Epic, Issue, Task, UserStory, WikiPage
+from taiga.models import Issue, Task, UserStory, WikiPage
 
 from .tools import MockResponse, create_mock_json
 
@@ -21,10 +21,8 @@ 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))