Private (visible=False/True) albums are no longer supported.

Tag count is now returned as an integer
Explicitly add test tags, rather than removing autogenerated tags
This commit is contained in:
Pete 2013-02-09 16:54:14 +00:00 committed by sneakypete81
parent eeffec991f
commit 4ccdceb601
2 changed files with 10 additions and 22 deletions

View file

@ -7,7 +7,7 @@ class TestAlbums(test_base.TestBase):
def test_create_delete(self): def test_create_delete(self):
""" Create an album then delete it """ """ Create an album then delete it """
album_name = "create_delete_album" album_name = "create_delete_album"
album = self.client.album.create(album_name, visible=True) album = self.client.album.create(album_name)
# Check the return value # Check the return value
self.assertEqual(album.name, album_name) self.assertEqual(album.name, album_name)
@ -20,7 +20,7 @@ class TestAlbums(test_base.TestBase):
self.assertNotIn(album_name, [a.name for a in self.client.albums.list()]) self.assertNotIn(album_name, [a.name for a in self.client.albums.list()])
# Create it again, and delete it using the Album object # Create it again, and delete it using the Album object
album = self.client.album.create(album_name, visible=True) album = self.client.album.create(album_name)
album.delete() album.delete()
# Check that the album is now gone # Check that the album is now gone
self.assertNotIn(album_name, [a.name for a in self.client.albums.list()]) self.assertNotIn(album_name, [a.name for a in self.client.albums.list()])
@ -61,18 +61,6 @@ class TestAlbums(test_base.TestBase):
for photo in self.photos: for photo in self.photos:
self.assertIn(photo.id, [p.id for p in album.photos]) self.assertIn(photo.id, [p.id for p in album.photos])
@unittest.expectedFailure # Private albums are not visible - issue #929
def test_private(self):
""" Test that private albums can be created, and are visible """
# Create and check that the album now exists
album_name = "private_album"
album = self.client.album.create(album_name, visible=False)
self.assertIn(album_name, [a.name for a in self.client.albums.list()])
# Delete and check that the album is now gone
album.delete()
self.assertNotIn(album_name, [a.name for a in self.client.albums.list()])
def test_form(self): def test_form(self):
""" If album.form gets implemented, write a test! """ """ If album.form gets implemented, write a test! """
with self.assertRaises(openphoto.NotImplementedError): with self.assertRaises(openphoto.NotImplementedError):

View file

@ -61,6 +61,7 @@ class TestBase(unittest.TestCase):
""" """
self.photos = self.client.photos.list() self.photos = self.client.photos.list()
if len(self.photos) != 3: if len(self.photos) != 3:
# print self.photos
print "[Regenerating Photos]" print "[Regenerating Photos]"
if len(self.photos) > 0: if len(self.photos) > 0:
self._delete_all() self._delete_all()
@ -70,7 +71,7 @@ class TestBase(unittest.TestCase):
self.tags = self.client.tags.list() self.tags = self.client.tags.list()
if (len(self.tags) != 1 or if (len(self.tags) != 1 or
self.tags[0].id != self.TEST_TAG or self.tags[0].id != self.TEST_TAG or
self.tags[0].count != "3"): self.tags[0].count != 3):
print "[Regenerating Tags]" print "[Regenerating Tags]"
self._delete_all() self._delete_all()
self._create_test_photos() self._create_test_photos()
@ -97,22 +98,21 @@ class TestBase(unittest.TestCase):
@classmethod @classmethod
def _create_test_photos(cls): def _create_test_photos(cls):
""" Upload three test photos """ """ Upload three test photos """
album = cls.client.album.create(cls.TEST_ALBUM, visible=True) album = cls.client.album.create(cls.TEST_ALBUM)
photos = [ photos = [
cls.client.photo.upload_encoded("tests/test_photo1.jpg", cls.client.photo.upload_encoded("tests/test_photo1.jpg",
title=cls.TEST_TITLE, title=cls.TEST_TITLE,
tags=cls.TEST_TAG), albums=album.id),
cls.client.photo.upload_encoded("tests/test_photo2.jpg", cls.client.photo.upload_encoded("tests/test_photo2.jpg",
title=cls.TEST_TITLE, title=cls.TEST_TITLE,
tags=cls.TEST_TAG), albums=album.id),
cls.client.photo.upload_encoded("tests/test_photo3.jpg", cls.client.photo.upload_encoded("tests/test_photo3.jpg",
title=cls.TEST_TITLE, title=cls.TEST_TITLE,
tags=cls.TEST_TAG), albums=album.id),
] ]
# Remove the auto-generated month/year tags # Add the test tag, removing any autogenerated tags
tags_to_remove = [p for p in photos[0].tags if p != cls.TEST_TAG]
for photo in photos: for photo in photos:
photo.update(tagsRemove=tags_to_remove, albums=album.id) photo.update(tags=cls.TEST_TAG)
@classmethod @classmethod
def _delete_all(cls): def _delete_all(cls):