from __future__ import unicode_literals import trovebox from tests.functional import test_base class TestPhotos(test_base.TestBase): testcase_name = "photo API" def test_delete_upload(self): """ Test photo deletion and upload """ # Delete one photo using the Trovebox class, passing in the id self.assertTrue(self.client.photo.delete(self.photos[0].id)) # Delete one photo using the Trovebox class, passing in the object self.assertTrue(self.client.photo.delete(self.photos[1])) # And another using the Photo object directly self.assertTrue(self.photos[2].delete()) # Check that they're gone self.assertEqual(self.client.photos.list(), []) # Re-upload the photos, one of them using Base64 encoding ret_val = self.client.photo.upload("tests/data/test_photo1.jpg", title=self.TEST_TITLE) self.client.photo.upload("tests/data/test_photo2.jpg", title=self.TEST_TITLE) self.client.photo.upload_encoded("tests/data/test_photo3.jpg", title=self.TEST_TITLE) # Check there are now three photos with the correct titles self.photos = self.client.photos.list() self.assertEqual(len(self.photos), 3) for photo in self.photos: self.assertEqual(photo.title, self.TEST_TITLE) # 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.assertTrue(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 Trovebox class html = self.client.photo.edit(self.photos[0]) self.assertIn("