Removing aspect functionality moved from Client() to streams.Aspects()
authorMarek Marecki <triviuss@gmail.com>
Fri, 3 May 2013 12:02:18 +0000 (14:02 +0200)
committerMarek Marecki <triviuss@gmail.com>
Fri, 3 May 2013 12:02:18 +0000 (14:02 +0200)
diaspy/client.py
diaspy/streams.py
tests.py

index 64a8ddc10b4d10e4ab50d99ed404eef02493f739..29730878a44a8c92b462309ac0bc47dc9bec0efc 100644 (file)
@@ -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.
index 5b1fb1d25d105dd73966b3f024c179e6f1a2b4ae..b60982c40a358f33c9b25dd8d23774adadf0e5d2 100644 (file)
@@ -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
index 548592550b8a911eda2a303ad9b9fd7c90c283d5..ca45fc48dffac4cdc79c1eb4c6bf290ca567fb1a 100644 (file)
--- 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):