def test_create_photo(self): root_folder = getattr(settings, 'PHOTOS_ROOT_DIR', '/') photo = Photo(root_folder, "album2", 'photo_first.JPG') self.assertEquals(photo.filename, 'photo_first.JPG') photo.load_name() self.assertEquals(photo.name, 'photo first') self.assertTrue(photo.exists()) self.assertEquals(photo.relative_url(), 'album2/photo_first.JPG')
def get_object(self): photo_path = self.kwargs['photo'] photo = None if photo_path: parts = photo_path.split('/') if len(parts) == 1: album = '' filename = parts[0] else: album = '/'.join(parts[:-1]) filename = parts[-1] photo = Photo(self.get_photo_base(), album, filename) if not photo or not photo.exists(): raise Http404 return photo