mirror of
https://github.com/beetbox/beets.git
synced 2026-02-21 23:03:26 +01:00
Add permissions test case for set_art event
This commit is contained in:
parent
264e771e7c
commit
f5e336747a
2 changed files with 20 additions and 1 deletions
|
|
@ -81,7 +81,6 @@ class Permissions(BeetsPlugin):
|
|||
files.append(item.path)
|
||||
dirs.update(dirs_in_library(lib.directory, item.path))
|
||||
elif album:
|
||||
files = []
|
||||
for album_item in album.items():
|
||||
files.append(album_item.path)
|
||||
dirs.update(dirs_in_library(lib.directory, album_item.path))
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import unittest
|
|||
from mock import patch, Mock
|
||||
|
||||
from test.helper import TestHelper
|
||||
from test._common import touch
|
||||
from beets.util import displayable_path
|
||||
from beetsplug.permissions import (check_permissions,
|
||||
convert_perm,
|
||||
|
|
@ -82,6 +83,25 @@ class PermissionsPluginTest(unittest.TestCase, TestHelper):
|
|||
def test_convert_perm_from_int(self):
|
||||
self.assertEqual(convert_perm(10), 8)
|
||||
|
||||
def test_permissions_on_set_art(self):
|
||||
self.do_set_art(True)
|
||||
|
||||
@patch("os.chmod", Mock())
|
||||
def test_failing_permissions_on_set_art(self):
|
||||
self.do_set_art(False)
|
||||
|
||||
def do_set_art(self, expect_success):
|
||||
if platform.system() == 'Windows':
|
||||
self.skipTest('permissions not available on Windows')
|
||||
self.importer = self.create_importer()
|
||||
self.importer.run()
|
||||
album = self.lib.albums().get()
|
||||
artpath = os.path.join(self.temp_dir, b'cover.jpg')
|
||||
touch(artpath)
|
||||
album.set_art(artpath)
|
||||
self.assertEqual(expect_success,
|
||||
check_permissions(album.artpath, 0o777))
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue