diff --git a/tests/functional/test_photos.py b/tests/functional/test_photos.py index 2540953..92b6cd5 100644 --- a/tests/functional/test_photos.py +++ b/tests/functional/test_photos.py @@ -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 diff --git a/tests/unit/test_photos.py b/tests/unit/test_photos.py index f55ba61..d9c7899 100644 --- a/tests/unit/test_photos.py +++ b/tests/unit/test_photos.py @@ -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): diff --git a/trovebox/api/api_photo.py b/trovebox/api/api_photo.py index 8633969..006da7c 100644 --- a/trovebox/api/api_photo.py +++ b/trovebox/api/api_photo.py @@ -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/[/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): """