1. b7w
  2. bviewer

Commits

b7w  committed 3436b3f

Fix tests for new storage behavior

  • Participants
  • Parent commits 6c6c53c
  • Branches dev

Comments (0)

Files changed (4)

File bviewer/api/tests/test_edit.py

View file
 
         self.new_gallery = dict(description='New gallery', user=user_id, url='test')
         self.new_album = dict(title='New album', gallery=gallery_id)
-        self.new_image = dict(path='image1.jpg', album=album_id)
-        self.data.generate_image(self.data.gallery_b7w.home, 'image1.jpg')
+        self.new_image = dict(path='b7w_home/image1.jpg', album=album_id)
+        self.data.generate_image('b7w_home/image1.jpg')
         self.new_video = dict(uid='123456', title='New', album=album_id)
 
     def test_public_post(self):

File bviewer/core/tests/base.py

View file
 # -*- coding: utf-8 -*-
 import os
 import shutil
+
 from mock import Mock
-
 from django.conf import settings
 from django.core import urlresolvers
 from django.test import TestCase

File bviewer/core/tests/data.py

View file
         user.save()
 
     def load_galleries(self):
-        self.gallery_b7w = Gallery(user=self.user_b7w)
+        self.gallery_b7w = Gallery(user=self.user_b7w, home='b7w_home')
         self.gallery_b7w.save()
-        self.gallery_keks = Gallery(user=self.user_keks)
+        self.gallery_keks = Gallery(user=self.user_keks, home='keks_home')
         self.gallery_keks.save()
         return self
 
         self.album5.save()
         return self
 
-    def generate_image(self, home, name, force=False):
+    def generate_image(self, name, force=False):
         """
         Create random image in settings.VIEWER_STORAGE_PATH if not exists.
         Or user `force=True` to override.
         """
-        path = os.path.join(settings.VIEWER_STORAGE_PATH, home, name)
+        path = os.path.join(settings.VIEWER_STORAGE_PATH, name)
         if not os.path.exists(os.path.dirname(path)):
             os.makedirs(os.path.dirname(path))
         if not os.path.exists(path) or force:
             image.save(path)
 
     def load_images(self):
-        self.image1 = Image.objects.create(album=self.album1, path='image1.jpg')
-        self.image2 = Image.objects.create(album=self.album1, path='image2.jpg')
-        self.generate_image(self.album1.gallery.home, self.image1.path)
-        self.generate_image(self.album1.gallery.home, self.image2.path)
+        self.image1 = Image.objects.create(album=self.album1, path='b7w_home/image1.jpg')
+        self.image2 = Image.objects.create(album=self.album1, path='b7w_home/image2.jpg')
+        self.generate_image(self.image1.path)
+        self.generate_image(self.image2.path)
 
-        self.image3 = Image.objects.create(album=self.album2, path='image3.jpg')
-        self.image4 = Image.objects.create(album=self.album2, path='image4.jpg')
-        self.generate_image(self.album2.gallery.home, self.image3.path)
-        self.generate_image(self.album2.gallery.home, self.image4.path)
+        self.image3 = Image.objects.create(album=self.album2, path='b7w_home/image3.jpg')
+        self.image4 = Image.objects.create(album=self.album2, path='b7w_home/image4.jpg')
+        self.generate_image(self.image3.path)
+        self.generate_image(self.image4.path)
 
-        self.image5 = Image.objects.create(album=self.album5, path='image5.jpg')
-        self.generate_image(self.album5.gallery.home, self.image5.path)
+        self.image5 = Image.objects.create(album=self.album5, path='keks_home/image5.jpg')
+        self.generate_image(self.image5.path)
         return self
 
     def load_videos(self):

File bviewer/core/tests/test_images.py

View file
 # -*- coding: utf-8 -*-
 from datetime import datetime
+
 from django.utils.timezone import utc
 
 from bviewer.core.images import CacheImage
         super(CacheImageTestCase, self).setUp()
         self.data = TestData()
         self.path = 'image1.jpg'
-        self.data.generate_image(self.gallery.home, self.path)
+        self.data.generate_image(self.gallery.home + '/' + self.path)
 
     def assertCacheImage(self, options, download=False):
         image_path = self.storage.get_path(self.path, options)
         super(ExifTest, self).setUp()
         self.data = TestData()
         self.path = 'image1.jpg'
-        self.data.generate_image(self.gallery.home, self.path)
+        self.data.generate_image(self.gallery.home + '/' + self.path)
 
     def test_ctime(self):
         exif = self.storage.exif(self.path)