self._connection = connection
self.post_id = post_id
+ def __repr__(self):
+ """Returns string containing more information then str().
+ """
+ data = self.get_data()
+ return '{0} ({1}): {2}'.format(data['author']['name'], data['author']['diaspora_id'], data['text'])
+
def __str__(self):
"""Returns text of a post.
"""
else: id = self._getaid(request)
return id
- def remove(self, aspect_id):
+ def remove(self, aspect_id=0, name=''):
"""This method removes an aspect.
500 is accepted because although the D* will
go nuts it will remove the aspect anyway.
:param aspect_id: id fo aspect to remove
:type aspect_id: int
+ :param name: name of aspect to remove
+ :type name: str
"""
+ if not aspect_id and name: aspect_id = self.getID(name)
data = {'authenticity_token': self._connection.get_token()}
request = self._connection.delete('aspects/{}'.format(aspect_id),
data=data)
def testAspectsAdd(self):
aspects = diaspy.streams.Aspects(test_connection)
test_aspect_id = aspects.add('diaspy-test')
+ aspects.add('diaspy-test-false')
def testAspectsGettingID(self):
aspects = diaspy.streams.Aspects(test_connection)
- id = aspects.getID('Coding')
+ id = aspects.getID('diaspy-test')
self.assertEqual(int, type(id))
- self.assertNotEqual(-1, id)
+ self.assertEqual(test_aspect_id, id)
- def testAspectsRemove(self):
+ def testAspectsRemoveById(self):
aspects = diaspy.streams.Aspects(test_connection)
aspects.remove(test_aspect_id)
+ def testAspectsRemoveByName(self):
+ aspects = diaspy.streams.Aspects(test_connection)
+ aspects.remove(name='diaspy-test-false')
+
def testActivity(self):
activity = diaspy.streams.Activity(test_connection)
self.assertEqual(type(user.stream), diaspy.streams.Outer)
+class PostTests(unittest.TestCase):
+ def testStringConversion(self):
+ s = diaspy.streams.Stream(test_connection)
+ print(str(s[0]))
+
+ def testRepr(self):
+ s = diaspy.streams.Stream(test_connection)
+ print(repr(s[0]))
+
+
if __name__ == '__main__': unittest.main()