Frontend issue 927 is now fixed, so the tag.create endpoint can be used.

The tag.create endpoint doesn't return the newly created tag - it is invisible, since it has no photos.
This commit is contained in:
sneakypete81 2013-03-23 18:17:09 +00:00
parent 29b4c65b9a
commit b56e690d33
2 changed files with 18 additions and 17 deletions

View file

@ -15,9 +15,8 @@ class ApiTag:
self._client = client self._client = client
def create(self, tag, **kwds): def create(self, tag, **kwds):
""" Create a new tag and return it """ """ Create a new tag. The API returns true if the tag was sucessfully created """
result = self._client.post("/tag/create.json", tag=tag, **kwds)["result"] return self._client.post("/tag/create.json", tag=tag, **kwds)["result"]
return Tag(self._client, result)
def delete(self, tag, **kwds): def delete(self, tag, **kwds):
""" Delete a tag """ """ Delete a tag """

View file

@ -3,31 +3,33 @@ import openphoto
import test_base import test_base
class TestTags(test_base.TestBase): class TestTags(test_base.TestBase):
@unittest.expectedFailure # Tag create fails - Issue #927 def test_create_delete(self, tag_id="create_tag"):
# NOTE: the below has not been tested/debugged, since it fails at the first step
def test_create_delete(self, tag_name="create_tag"):
""" Create a tag then delete it """ """ Create a tag then delete it """
# Create a tag # Create a tag
tag = self.client.tag.create(tag_name) self.assertTrue(self.client.tag.create(tag_id))
# Check that the tag doesn't exist (It has no photos, so it's invisible)
self.assertNotIn(tag_id, [t.id for t in self.client.tags.list()])
# Check the return value # Create a tag on one of the photos
self.assertEqual(tag.id, tag_name) self.photos[0].update(tagsAdd=tag_id)
# Check that the tag now exists # Check that the tag now exists
self.assertIn(tag_name, self.client.tags.list()) self.assertIn(tag_id, [t.id for t in self.client.tags.list()])
# Delete the tag # Delete the tag
self.client.tag.delete(tag_name) self.client.tag.delete(tag_id)
# Check that the tag is now gone # Check that the tag is now gone
self.assertNotIn(tag_name, self.client.tags.list()) self.assertNotIn(tag_id, [t.id for t in self.client.tags.list()])
# Create and delete using the Tag object directly # Create then delete using the Tag object directly
tag = self.client.tag.create(tag_name) self.photos[0].update(tagsAdd=tag_id)
tag = [t for t in self.client.tags.list() if t.id == tag_id][0]
tag.delete() tag.delete()
# Check that the tag is now gone # Check that the tag is now gone
self.assertNotIn(tag_name, self.client.tags.list()) self.assertNotIn(tag_id, [t.id for t in self.client.tags.list()])
@unittest.expectedFailure # Tag update fails - Issue #927 # NOTE: this test doesn't work, since it's not possible to update the tag owner
# NOTE: the below has not been tested/debugged, since it fails at the first step # It's unclear what tag/update is for, since there are no fields that can be updated!
@unittest.skip
def test_update(self): def test_update(self):
""" Test that a tag can be updated """ """ Test that a tag can be updated """
# Update the tag using the OpenPhoto class, passing in the tag object # Update the tag using the OpenPhoto class, passing in the tag object