From: Marek Marecki Date: Thu, 8 Aug 2013 16:51:06 +0000 (+0200) Subject: Imporved error message in diaspy.streams.Stream()._photoupload() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2d4f6eeba2ecb432d44e995786de5eab9f941000;p=diaspy.git Imporved error message in diaspy.streams.Stream()._photoupload() --- diff --git a/diaspy/streams.py b/diaspy/streams.py index 461fb03..6da1d82 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -204,7 +204,7 @@ class Stream(Generic): request = self._connection.post('photos', data=image, params=params, headers=headers) if request.status_code != 200: - raise Exception('wrong error code: {0}'.format(request.status_code)) + raise errors.StreamError('photo cannot be uploaded: {0}'.format(request.status_code)) return request.json()['data']['photo']['id'] diff --git a/tests.py b/tests.py index 2949be9..b7f500f 100644 --- a/tests.py +++ b/tests.py @@ -110,10 +110,14 @@ class StreamTest(unittest.TestCase): post = stream.post(post_text) self.assertEqual(diaspy.models.Post, type(post)) - @unittest.skip('returns internal server error -- not our fault that it is failing') def testPostingImage(self): stream = diaspy.streams.Stream(test_connection) - stream.post(text=post_text, photo='test-image.png') + try: + stream.post(text=post_text, photo='test-image.png') + except (StreamError) as e: + warnings.warn('{0}') + finally: + pass def testingAddingTag(self): ft = diaspy.streams.FollowedTags(test_connection)