From 2d4f6eeba2ecb432d44e995786de5eab9f941000 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Thu, 8 Aug 2013 18:51:06 +0200 Subject: [PATCH] Imporved error message in diaspy.streams.Stream()._photoupload() --- diaspy/streams.py | 2 +- tests.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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) -- 2.25.1