Commits

b7w committed 62cefb1

Tests fix

  • Participants
  • Parent commits 791e8e8

Comments (0)

Files changed (5)

File bviewer/api/tests/test_edit.py

         gallery_id = self.data.gallery_b7w.id
         album_id = self.data.album_b7w.id
 
-        self.new_gallery = dict(title='New gallery', user=user_id, url='test')
+        self.new_gallery = dict(user=user_id, url='test', description='New gallery', )
         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')

File bviewer/core/controllers.py

     @staticmethod
     def from_obj(obj):
         """
-        :type obj: bviewer.core.models.Album
+        :type obj: bviewer.core.models.Gallery
         """
-        return AlbumController(obj.gallery, obj.gallery.user, obj=obj)
+        return AlbumController(obj, obj.user, obj=obj.top_album)
 
     @cache_method
     def get_object(self):

File bviewer/core/tests/test_controllers.py

         gallery = data.gallery_b7w
         top_album = gallery.top_album
 
-        controller = AlbumController(gallery, gallery, uid=top_album.id)
+        controller = AlbumController(gallery, gallery.user, uid=top_album.id)
         self.assertEqual(controller.uid, top_album.id)
         self.assertIsNone(controller.obj)
         self.assertEqual(controller.get_object(), top_album)
 
-        controller = AlbumController(gallery, gallery, obj=top_album)
+        controller = AlbumController(gallery, gallery.user, obj=top_album)
         self.assertEqual(controller.uid, top_album.id)
         self.assertEqual(controller.obj, top_album)
         self.assertEqual(controller.get_object(), top_album)

File bviewer/core/tests/test_files.py

                 self.assertEqual(func(image_path, for_cache=True), for_cache)
 
         gallery = Mock(home='home', url='url', cache_size=0)
-        storage = ImageStorage(gallery, root_path='root', cache_path='cache')
+        # Storage pre create cache dir, fix it
+        with patch('os.makedirs'):
+            storage = ImageStorage(gallery, root_path='root', cache_path='cache')
 
         assert_method_for_cache('os.path.getctime', storage.ctime, side_effect=str)
         assert_method_for_cache('os.path.exists', storage.exists, side_effect=str)

File bviewer/profile/admin.py

     list_display = ('url', 'top_album', 'description', )
     exclude = ('user',)
 
-    readonly_fields = ('cache_info', )
+    readonly_fields = ('home', 'cache_info', )
 
     ordering = ('url',)