import unittest import openphoto import test_base class TestPhotos(test_base.TestBase): def test_delete_upload(self): """ Test photo deletion and upload """ # Delete one photo using the OpenPhoto class, passing in the id self.client.photo.delete(self.photos[0].id) # Delete one photo using the OpenPhoto class, passing in the object self.client.photo.delete(self.photos[1]) # And another using the Photo object directly self.photos[2].delete() # Check that they're gone self.assertEqual(self.client.photos.list(), []) # Re-upload the photos ret_val = self.client.photo.upload_encoded("tests/test_photo1.jpg", title=self.TEST_TITLE) self.client.photo.upload_encoded("tests/test_photo2.jpg", title=self.TEST_TITLE) self.client.photo.upload_encoded("tests/test_photo3.jpg", title=self.TEST_TITLE) # Check there are now three photos self.photos = self.client.photos.list() self.assertEqual(len(self.photos), 3) # Check that the upload return value was correct pathOriginals = [photo.pathOriginal for photo in self.photos] self.assertIn(ret_val.pathOriginal, pathOriginals) # Delete all photos in one go self.client.photos.delete(self.photos) # Check they're gone self.photos = self.client.photos.list() self.assertEqual(len(self.photos), 0) # Regenerate the original test photos self._delete_all() self._create_test_photos() def test_edit(self): """ Check that the edit request returns an HTML form """ # Test using the OpenPhoto class html = self.client.photo.edit(self.photos[0]) self.assertIn("