Small changes in connection
authorMarek Marecki <marekjm@taistelu.com>
Tue, 20 Aug 2013 10:59:51 +0000 (12:59 +0200)
committerMarek Marecki <marekjm@taistelu.com>
Tue, 20 Aug 2013 10:59:51 +0000 (12:59 +0200)
Changelog.markdown
diaspy/connection.py
tests.py

index 304079c9b86afb3103a7cc6200d9c15a2221d557..eeb9e7725f240620d600f1bdfbc9eb123b5161c2 100644 (file)
@@ -19,6 +19,12 @@ up-to-date than manual and if conflicts appear they should follow the order:
 *docstrings* -> *docs/* -> *manual/*
 
 
+----
+
+Version `0.3.2` (2013-08-):
+
+* __upd__:  `diaspy.connection.getUserData()` raises `DiaspyError` when it cannot find user data,
+
 ----
 
 Version `0.3.1` (2013-07-12):
index 3c1a0be1a489cc603c366c86f8f0e0e78f568ecd..8654b068ede0c4c2acc4e7884fbe8ec3c404592e 100644 (file)
@@ -19,8 +19,7 @@ class TokenError(Exception):
 
 
 class Connection():
-    """Object representing connection with the server.
-    It is pushed around internally and is considered private.
+    """Object representing connection with the pod.
     """
     _token_regex = re.compile(r'content="(.*?)"\s+name="csrf-token')
     _userinfo_regex = re.compile(r'window.current_user_attributes = ({.*})')
@@ -157,7 +156,10 @@ class Connection():
         :returns: dict -- json formatted user info.
         """
         request = self.get('bookmarklet')
-        userdata = json.loads(self._userinfo_regex.search(request.text).group(1))
+        try:
+            userdata = json.loads(self._userinfo_regex.search(request.text).group(1))
+        except AttributeError:
+            raise errors.DiaspyError('cannot find user data')
         return userdata
 
     def _fetchtoken(self):
index a45be30d5784e3af98a79fb2584f3a08ea9a8fd9..57fac8684e270a5e563ffa09dc1d482d5046cdca 100644 (file)
--- a/tests.py
+++ b/tests.py
@@ -114,7 +114,7 @@ class StreamTest(unittest.TestCase):
         stream = diaspy.streams.Stream(test_connection)
         try:
             stream.post(text=post_text, photo='test-image.png')
-        except (StreamError) as e:
+        except (diaspy.errors.StreamError) as e:
             warnings.warn('{0}')
         finally:
             pass