Added photos/share endpoint (currently not implemented in frontend)

This commit is contained in:
sneakypete81 2013-09-11 17:27:21 +01:00
parent e904a629f9
commit 6b3f010920
3 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,10 @@
from __future__ import unicode_literals
try:
import unittest2 as unittest # Python2.6
except ImportError:
import unittest
import trovebox
from tests.functional import test_base
@ -22,6 +27,12 @@ class TestPhotos(test_base.TestBase):
# Put the environment back the way we found it
photos[0].update(tagsRemove=filter_tag)
# Photo share endpoint is currently not implemented
@unittest.expectedFailure
def test_share(self):
""" Test photo sharing (currently not implemented) """
self.client.photos.share()
def test_delete_upload(self):
""" Test photo deletion and upload """
# Delete one photo using the Trovebox class, passing in the id

View file

@ -68,6 +68,18 @@ class TestPhotosList(TestPhotos):
("/photos/test1-test2/foo-bar/list.json",)])
self.assertEqual(mock_get.call_args[1], {"foo": "bar"})
class TestPhotosList(TestPhotos):
@mock.patch.object(trovebox.Trovebox, 'post')
def test_photos_share(self, mock_post):
self.client.photos.share(filters={"foo": "bar",
"test1": "test2"},
foo="bar")
# Dict element can be any order
self.assertIn(mock_post.call_args[0],
[("/photos/foo-bar/test1-test2/share.json",),
("/photos/test1-test2/foo-bar/share.json",)])
self.assertEqual(mock_post.call_args[1], {"foo": "bar"})
class TestPhotosUpdate(TestPhotos):
@mock.patch.object(trovebox.Trovebox, 'post')
def test_photos_update(self, mock_post):

View file

@ -23,7 +23,15 @@ class ApiPhotos(ApiBase):
photos = self._result_to_list(photos)
return [Photo(self._client, photo) for photo in photos]
# def share(self, **kwds):
def share(self, filters=None, **kwds):
"""
Endpoint: /photos/[<filters>/share.json
Not currently implemented.
"""
filter_string = self._build_filter_string(filters)
return self._client.post("/photos/%sshare.json" % filter_string,
**kwds)["result"]
def delete(self, photos, **kwds):
"""