mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 09:04:33 +01:00
Don't mutate the base classes. This was causing plugins to break on the second test that uses them, since after they were unloaded their class-level fields were broken (since the modules are not re-loaded). This makes it more clear than ever that we need to encapsulate plugin loading state using some manner of PluginManager.
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Tests for the 'permissions' plugin.
|
|
"""
|
|
from _common import unittest
|
|
from helper import TestHelper
|
|
from beetsplug.permissions import check_permissions, convert_perm
|
|
|
|
|
|
class PermissionsPluginTest(unittest.TestCase, TestHelper):
|
|
def setUp(self):
|
|
self.setup_beets()
|
|
self.load_plugins('permissions')
|
|
|
|
self.config['permissions'] = {
|
|
'file': 777}
|
|
|
|
def tearDown(self):
|
|
self.teardown_beets()
|
|
self.unload_plugins()
|
|
|
|
def test_permissions_on_album_imported(self):
|
|
self.importer = self.create_importer()
|
|
self.importer.run()
|
|
item = self.lib.items().get()
|
|
config_perm = self.config['permissions']['file'].get()
|
|
config_perm = convert_perm(config_perm)
|
|
|
|
self.assertTrue(check_permissions(item.path, config_perm))
|
|
self.assertFalse(check_permissions(item.path, convert_perm(644)))
|
|
|
|
def test_permissions_on_item_imported(self):
|
|
self.config['import']['singletons'] = True
|
|
self.importer = self.create_importer()
|
|
self.importer.run()
|
|
item = self.lib.items().get()
|
|
config_perm = self.config['permissions']['file'].get()
|
|
config_perm = convert_perm(config_perm)
|
|
|
|
self.assertTrue(check_permissions(item.path, config_perm))
|
|
self.assertFalse(check_permissions(item.path, convert_perm(644)))
|
|
|
|
|
|
def suite():
|
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main(defaultTest='suite')
|