From fbb199002b4320f61bea8261c74d94f1b70c188b Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Fri, 3 May 2013 14:02:18 +0200 Subject: [PATCH] Removing aspect functionality moved from Client() to streams.Aspects() --- diaspy/client.py | 11 +++-------- diaspy/streams.py | 21 ++++++++++++++++++++- tests.py | 4 ++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/diaspy/client.py b/diaspy/client.py index 64a8ddc..2973087 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -178,15 +178,10 @@ class Client: return r.json() def remove_aspect(self, aspect_id): - """ This function adds a new aspect. + """ This function removes an aspect. """ - data = {'authenticity_token': self.connection.get_token()} - - r = self.connection.delete('aspects/{}'.format(aspect_id), - data=data) - - if r.status_code != 404: - raise Exception('wrong status code: {0}'.format(r.status_code)) + aspects = diaspy.streams.Aspects(self.connection) + aspects.remove(aspect_id) def new_conversation(self, contacts, subject, text): """Start a new conversation. diff --git a/diaspy/streams.py b/diaspy/streams.py index 5b1fb1d..b60982c 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -228,6 +228,15 @@ class Aspects(Generic): if r.status_code != 200: raise Exception('wrong status code: {0}'.format(r.status_code)) + def remove(self, aspect_id): + """This method removes an aspect. + """ + data = {'authenticity_token': self.connection.get_token()} + r = self.connection.delete('aspects/{}'.format(aspect_id), + data=data) + if r.status_code != 404: + raise Exception('wrong status code: {0}'.format(r.status_code)) + class Commented(Generic): """This stream contains all posts @@ -259,7 +268,17 @@ class FollowedTags(Generic): def _setlocation(self): self._location = 'followed_tags.json' - def create(self, tag_name): + def remove(self, tag_name): + """Stop following a tag. + + :param tag_name: tag name + :type tag_name: str + """ + data = {} + headers = {} + request = None + + def add(self, tag_name): """Follow new tag. :param tag_name: tag name diff --git a/tests.py b/tests.py index 5485925..ca45fc4 100644 --- a/tests.py +++ b/tests.py @@ -69,6 +69,10 @@ class StreamTest(unittest.TestCase): stream = diaspy.streams.Stream(test_connection) stream.post_picture('./test-image.png') + def testCreatingTag(self): + ft = diaspy.streams.FollowedTags(test_connection) + ft.create('test') + class ConnectionTest(unittest.TestCase): def testLoginWithoutUsername(self): -- 2.25.1