Merge branch 'master' into api_versioning
Conflicts: tests/test_base.py
This commit is contained in:
commit
c7c3b4bdb5
4 changed files with 27 additions and 18 deletions
|
@ -43,10 +43,7 @@ class ApiAlbum:
|
|||
if not isinstance(album, Album):
|
||||
album = Album(self._client, {"id": album})
|
||||
album.update(**kwds)
|
||||
|
||||
# Don't return the album, since the API currently doesn't give us the modified album
|
||||
# TODO: Uncomment the following once frontend issue #937 is resolved
|
||||
# return album
|
||||
return album
|
||||
|
||||
def view(self, album, **kwds):
|
||||
"""
|
||||
|
|
|
@ -104,4 +104,11 @@ class ApiPhoto:
|
|||
return photo.next_previous(**kwds)
|
||||
|
||||
def transform(self, photo, **kwds):
|
||||
raise NotImplementedError()
|
||||
"""
|
||||
Performs transformation specified in **kwds
|
||||
Example: transform(photo, rotate=90)
|
||||
"""
|
||||
if not isinstance(photo, Photo):
|
||||
photo = Photo(self._client, {"id": photo})
|
||||
photo.transform(**kwds)
|
||||
return photo
|
||||
|
|
|
@ -107,8 +107,13 @@ class Photo(OpenPhotoObject):
|
|||
return value
|
||||
|
||||
def transform(self, **kwds):
|
||||
raise NotImplementedError()
|
||||
|
||||
"""
|
||||
Performs transformation specified in **kwds
|
||||
Example: transform(rotate=90)
|
||||
"""
|
||||
new_dict = self._openphoto.post("/photo/%s/transform.json" % self.id,
|
||||
**kwds)["result"]
|
||||
self._replace_fields(new_dict)
|
||||
|
||||
class Tag(OpenPhotoObject):
|
||||
def delete(self, **kwds):
|
||||
|
@ -167,14 +172,8 @@ class Album(OpenPhotoObject):
|
|||
""" Update this album with the specified parameters """
|
||||
new_dict = self._openphoto.post("/album/%s/update.json" % self.id,
|
||||
**kwds)["result"]
|
||||
|
||||
# Since the API doesn't give us the modified album, we need to
|
||||
# update our fields based on the kwds that were sent
|
||||
self._set_fields(kwds)
|
||||
|
||||
# Replace the above line with the below once frontend issue #937 is resolved
|
||||
# self._set_fields(new_dict)
|
||||
# self._update_fields_with_objects()
|
||||
self._replace_fields(new_dict)
|
||||
self._update_fields_with_objects()
|
||||
|
||||
def view(self, **kwds):
|
||||
"""
|
||||
|
|
|
@ -149,6 +149,12 @@ class TestPhotos(test_base.TestBase):
|
|||
self.client.photo.dynamic_url(None)
|
||||
|
||||
def test_transform(self):
|
||||
""" If photo.transform gets implemented, write a test! """
|
||||
with self.assertRaises(openphoto.NotImplementedError):
|
||||
self.client.photo.transform(None)
|
||||
""" Test photo rotation """
|
||||
photo = self.photos[0]
|
||||
self.assertEqual(photo.rotation, "0")
|
||||
photo = self.client.photo.transform(photo, rotate=90)
|
||||
self.assertEqual(photo.rotation, "90")
|
||||
|
||||
# Do the same using the Photo object directly
|
||||
photo.transform(rotate=90)
|
||||
self.assertEqual(photo.rotation, "180")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue