Repository: nephila/python-taiga (python)

Issue:
AttributeError: 'History' object has no attribute 'id'
Hi,

I think one of the latest taiga-back commits broke python-taiga if not entirely but quite badly.
I see they made changes to the history management in taiga-back (they fixed something with timeline history loops on fresh projects) and I suppose it had some effect on this tool.

This gets raised when I'm trying to get a project by its slug:
`AttributeError: 'History' object has no attribute 'id'`

Got no idea where to fix it yet.

Pull request description:
Fix repr error on History object
Fix the History object `repr` / `str`

Fix #78 

Patch:
diff --git a/taiga/models/base.py b/taiga/models/base.py
index cd6b4eb..90fa1d0 100644
--- a/taiga/models/base.py
+++ b/taiga/models/base.py
@@ -232,7 +232,10 @@ class InstanceResource(Resource):
         return cls(requester, **entry)
 
     def __repr__(self):
-        return '{0}({1})'.format(self.__class__.__name__, self.id)
+        try:
+            return '{0}({1})'.format(self.__class__.__name__, self.id)
+        except AttributeError:
+            return '{0}({1})'.format(self.__class__.__name__, id(self))
 
     def __str__(self):
         return self._rp()


Test patch:
diff --git a/tests/test_history.py b/tests/test_history.py
index 175000b..3ebb1f8 100644
--- a/tests/test_history.py
+++ b/tests/test_history.py
@@ -9,6 +9,16 @@ from .tools import MockResponse, create_mock_json
 
 class TestHistory(unittest.TestCase):
 
+    @patch('taiga.requestmaker.RequestMaker.get')
+    def test_history_repr(self, mock_requestmaker_get):
+        mock_requestmaker_get.return_value = MockResponse(
+            200,
+            create_mock_json('tests/resources/history_success.json')
+        )
+        api = TaigaAPI(token='f4k3')
+        api.history.issue.get(1)
+        self.assertTrue('History' in str(api.history))
+
     @patch('taiga.requestmaker.RequestMaker.get')
     def test_issue(self, mock_requestmaker_get):
         mock_requestmaker_get.return_value = MockResponse(