Don't explicitly raise a TroveboxError if False is returned,
rely on frontend to issue an error code. This also means we don't need to test for this in unit tests.
This commit is contained in:
parent
6b3f010920
commit
bf437ffc7e
10 changed files with 20 additions and 133 deletions
|
@ -98,13 +98,6 @@ class TestActionDelete(TestActions):
|
|||
mock_post.assert_called_with("/action/1/delete.json", foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_action_delete_failure(self, mock_post):
|
||||
"""Check that an exception is raised if an action cannot be deleted"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.action.delete(self.test_actions[0])
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_action_object_delete(self, mock_post):
|
||||
"""Check that an action can be deleted using the action object directly"""
|
||||
|
@ -116,16 +109,6 @@ class TestActionDelete(TestActions):
|
|||
self.assertEqual(action.get_fields(), {})
|
||||
self.assertEqual(action.id, None)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_action_object_delete_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if an action cannot be deleted
|
||||
when using the action object directly
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.test_actions[0].delete()
|
||||
|
||||
class TestActionView(TestActions):
|
||||
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||
def test_action_view(self, mock_get):
|
||||
|
|
|
@ -91,13 +91,6 @@ class TestActivitiesPurge(TestActivities):
|
|||
mock_get.assert_called_with("/activities/purge.json", foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_activity_purge_failure(self, mock_post):
|
||||
"""Test activity purging """
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
result = self.client.activities.purge(foo="bar")
|
||||
|
||||
class TestActivityView(TestActivities):
|
||||
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||
def test_activity_view(self, mock_get):
|
||||
|
|
|
@ -147,13 +147,6 @@ class TestAlbumDelete(TestAlbums):
|
|||
mock_post.assert_called_with("/album/1/delete.json", foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_album_delete_failure(self, mock_post):
|
||||
"""Check that an exception is raised if an album cannot be deleted"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.album.delete(self.test_albums[0])
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_album_object_delete(self, mock_post):
|
||||
"""Check that an album can be deleted using the album object directly"""
|
||||
|
@ -166,16 +159,6 @@ class TestAlbumDelete(TestAlbums):
|
|||
self.assertEqual(album.id, None)
|
||||
self.assertEqual(album.name, None)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_album_object_delete_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if an album cannot be deleted
|
||||
when using the album object directly
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.test_albums[0].delete()
|
||||
|
||||
class TestAlbumAdd(TestAlbums):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_album_add(self, mock_post):
|
||||
|
|
|
@ -99,16 +99,6 @@ class TestPhotosUpdate(TestPhotos):
|
|||
ids=["1a", "2b"], title="Test")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photos_update_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if multiple photos
|
||||
cannot be updated
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.photos.update(self.test_photos, title="Test")
|
||||
|
||||
class TestPhotosDelete(TestPhotos):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photos_delete(self, mock_post):
|
||||
|
@ -128,16 +118,6 @@ class TestPhotosDelete(TestPhotos):
|
|||
ids=["1a", "2b"], foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photos_delete_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if multiple photos
|
||||
cannot be deleted
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.photos.delete(self.test_photos)
|
||||
|
||||
class TestPhotoDelete(TestPhotos):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photo_delete(self, mock_post):
|
||||
|
@ -155,13 +135,6 @@ class TestPhotoDelete(TestPhotos):
|
|||
mock_post.assert_called_with("/photo/1a/delete.json", foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photo_delete_failure(self, mock_post):
|
||||
"""Check that an exception is raised if a photo cannot be deleted"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.photo.delete(self.test_photos[0])
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photo_object_delete(self, mock_post):
|
||||
"""
|
||||
|
@ -176,16 +149,6 @@ class TestPhotoDelete(TestPhotos):
|
|||
self.assertEqual(photo.get_fields(), {})
|
||||
self.assertEqual(photo.id, None)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photo_object_delete_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if a photo cannot be deleted
|
||||
when using the photo object directly
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.test_photos[0].delete()
|
||||
|
||||
class TestPhotoReplace(TestPhotos):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_photo_replace(self, _):
|
||||
|
|
|
@ -78,13 +78,6 @@ class TestTagDelete(TestTags):
|
|||
mock_post.assert_called_with("/tag/tag1/delete.json", foo="bar")
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_tag_delete_failure(self, mock_post):
|
||||
"""Check that an exception is raised if a tag cannot be deleted"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.client.tag.delete(self.test_tags[0])
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_tag_object_delete(self, mock_post):
|
||||
"""Check that a tag can be deleted when using the tag object directly"""
|
||||
|
@ -96,16 +89,6 @@ class TestTagDelete(TestTags):
|
|||
self.assertEqual(tag.get_fields(), {})
|
||||
self.assertEqual(tag.id, None)
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_tag_object_delete_failure(self, mock_post):
|
||||
"""
|
||||
Check that an exception is raised if a tag cannot be deleted
|
||||
when using the tag object directly
|
||||
"""
|
||||
mock_post.return_value = self._return_value(False)
|
||||
with self.assertRaises(trovebox.TroveboxError):
|
||||
self.test_tags[0].delete()
|
||||
|
||||
class TestTagUpdate(TestTags):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_tag_update(self, mock_post):
|
||||
|
|
|
@ -39,12 +39,9 @@ class ApiAction(ApiBase):
|
|||
Returns True if successful.
|
||||
Raises a TroveboxError if not.
|
||||
"""
|
||||
result = self._client.post("/action/%s/delete.json" %
|
||||
return self._client.post("/action/%s/delete.json" %
|
||||
self._extract_id(action),
|
||||
**kwds)["result"]
|
||||
if not result:
|
||||
raise TroveboxError("Delete response returned False")
|
||||
return result
|
||||
|
||||
def view(self, action, **kwds):
|
||||
"""
|
||||
|
|
|
@ -27,11 +27,11 @@ class ApiActivities(ApiBase):
|
|||
Endpoint: /activities/purge.json
|
||||
|
||||
Purges all activities.
|
||||
Currently not working due to frontend issue #1368
|
||||
Returns True if successful.
|
||||
Raises a TroveboxError if not.
|
||||
Currently not working due to frontend issue #1368.
|
||||
"""
|
||||
if not self._client.post("/activities/purge.json", **kwds)["result"]:
|
||||
raise TroveboxError("Purge response returned False")
|
||||
return True
|
||||
return self._client.post("/activities/purge.json", **kwds)["result"]
|
||||
|
||||
class ApiActivity(ApiBase):
|
||||
""" Definitions of /activity/ API endpoints """
|
||||
|
|
|
@ -60,12 +60,9 @@ class ApiAlbum(ApiBase):
|
|||
Returns True if successful.
|
||||
Raises a TroveboxError if not.
|
||||
"""
|
||||
result = self._client.post("/album/%s/delete.json" %
|
||||
return self._client.post("/album/%s/delete.json" %
|
||||
self._extract_id(album),
|
||||
**kwds)["result"]
|
||||
if not result:
|
||||
raise TroveboxError("Delete response returned False")
|
||||
return result
|
||||
|
||||
def add(self, album, objects, object_type=None, **kwds):
|
||||
"""
|
||||
|
|
|
@ -42,10 +42,8 @@ class ApiPhotos(ApiBase):
|
|||
Raises a TroveboxError if not.
|
||||
"""
|
||||
ids = [self._extract_id(photo) for photo in photos]
|
||||
if not self._client.post("/photos/delete.json", ids=ids,
|
||||
**kwds)["result"]:
|
||||
raise TroveboxError("Delete response returned False")
|
||||
return True
|
||||
return self._client.post("/photos/delete.json", ids=ids,
|
||||
**kwds)["result"]
|
||||
|
||||
def update(self, photos, **kwds):
|
||||
"""
|
||||
|
@ -56,10 +54,8 @@ class ApiPhotos(ApiBase):
|
|||
Raises TroveboxError if not.
|
||||
"""
|
||||
ids = [self._extract_id(photo) for photo in photos]
|
||||
if not self._client.post("/photos/update.json", ids=ids,
|
||||
**kwds)["result"]:
|
||||
raise TroveboxError("Update response returned False")
|
||||
return True
|
||||
return self._client.post("/photos/update.json", ids=ids,
|
||||
**kwds)["result"]
|
||||
|
||||
class ApiPhoto(ApiBase):
|
||||
""" Definitions of /photo/ API endpoints """
|
||||
|
@ -71,14 +67,9 @@ class ApiPhoto(ApiBase):
|
|||
Returns True if successful.
|
||||
Raises a TroveboxError if not.
|
||||
"""
|
||||
result = self._client.post("/photo/%s/delete.json" %
|
||||
return self._client.post("/photo/%s/delete.json" %
|
||||
self._extract_id(photo),
|
||||
**kwds)["result"]
|
||||
if not result:
|
||||
raise TroveboxError("Delete response returned False")
|
||||
return result
|
||||
|
||||
# def delete_source(self, photo, **kwds):
|
||||
|
||||
def replace(self, photo, photo_file, **kwds):
|
||||
""" Not yet implemented """
|
||||
|
|
|
@ -42,12 +42,9 @@ class ApiTag(ApiBase):
|
|||
Returns True if successful.
|
||||
Raises a TroveboxError if not.
|
||||
"""
|
||||
result = self._client.post("/tag/%s/delete.json" %
|
||||
return self._client.post("/tag/%s/delete.json" %
|
||||
quote(self._extract_id(tag)),
|
||||
**kwds)["result"]
|
||||
if not result:
|
||||
raise TroveboxError("Delete response returned False")
|
||||
return result
|
||||
|
||||
def update(self, tag, **kwds):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue