mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
paths now normalized to absolute (issue 5)
--HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%4076
This commit is contained in:
parent
c5e06b6f73
commit
4ba801acb7
3 changed files with 8 additions and 9 deletions
|
|
@ -49,9 +49,7 @@ class InvalidFieldError(Exception):
|
||||||
def _normpath(path):
|
def _normpath(path):
|
||||||
"""Provide the canonical form of the path suitable for storing in the
|
"""Provide the canonical form of the path suitable for storing in the
|
||||||
database."""
|
database."""
|
||||||
# force absolute paths:
|
return os.path.normpath(os.path.abspath(os.path.expanduser(path)))
|
||||||
# os.path.normpath(os.path.abspath(os.path.expanduser(path)))
|
|
||||||
return os.path.normpath(os.path.expanduser(path))
|
|
||||||
|
|
||||||
def _log(msg):
|
def _log(msg):
|
||||||
"""Print a log message."""
|
"""Print a log message."""
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ def item(lib=None): return beets.library.Item({
|
||||||
'comp': True,
|
'comp': True,
|
||||||
'path': 'somepath',
|
'path': 'somepath',
|
||||||
}, lib)
|
}, lib)
|
||||||
|
np = beets.library._normpath
|
||||||
|
|
||||||
class LoadTest(unittest.TestCase):
|
class LoadTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
@ -122,12 +123,12 @@ class DestinationTest(unittest.TestCase):
|
||||||
def test_directory_works_with_trailing_slash(self):
|
def test_directory_works_with_trailing_slash(self):
|
||||||
self.lib.options['directory'] = 'one/'
|
self.lib.options['directory'] = 'one/'
|
||||||
self.lib.options['path_format'] = 'two'
|
self.lib.options['path_format'] = 'two'
|
||||||
self.assertEqual(self.i.destination(), 'one/two')
|
self.assertEqual(self.i.destination(), np('one/two'))
|
||||||
|
|
||||||
def test_directory_works_without_trailing_slash(self):
|
def test_directory_works_without_trailing_slash(self):
|
||||||
self.lib.options['directory'] = 'one'
|
self.lib.options['directory'] = 'one'
|
||||||
self.lib.options['path_format'] = 'two'
|
self.lib.options['path_format'] = 'two'
|
||||||
self.assertEqual(self.i.destination(), 'one/two')
|
self.assertEqual(self.i.destination(), np('one/two'))
|
||||||
|
|
||||||
def test_destination_substitues_metadata_values(self):
|
def test_destination_substitues_metadata_values(self):
|
||||||
self.lib.options['directory'] = 'base'
|
self.lib.options['directory'] = 'base'
|
||||||
|
|
@ -135,13 +136,13 @@ class DestinationTest(unittest.TestCase):
|
||||||
self.i.title = 'three'
|
self.i.title = 'three'
|
||||||
self.i.artist = 'two'
|
self.i.artist = 'two'
|
||||||
self.i.album = 'one'
|
self.i.album = 'one'
|
||||||
self.assertEqual(self.i.destination(), 'base/one/two three')
|
self.assertEqual(self.i.destination(), np('base/one/two three'))
|
||||||
|
|
||||||
def test_destination_substitutes_extension(self):
|
def test_destination_substitutes_extension(self):
|
||||||
self.lib.options['directory'] = 'base'
|
self.lib.options['directory'] = 'base'
|
||||||
self.lib.options['path_format'] = '$extension'
|
self.lib.options['path_format'] = '$extension'
|
||||||
self.i.path = 'hey.audioFormat'
|
self.i.path = 'hey.audioFormat'
|
||||||
self.assertEqual(self.i.destination(), 'base/audioFormat')
|
self.assertEqual(self.i.destination(), np('base/audioFormat'))
|
||||||
|
|
||||||
def test_destination_pads_some_indices(self):
|
def test_destination_pads_some_indices(self):
|
||||||
self.lib.options['directory'] = 'base'
|
self.lib.options['directory'] = 'base'
|
||||||
|
|
@ -153,7 +154,7 @@ class DestinationTest(unittest.TestCase):
|
||||||
self.i.disctotal = 4
|
self.i.disctotal = 4
|
||||||
self.i.bpm = 5
|
self.i.bpm = 5
|
||||||
self.i.year = 6
|
self.i.year = 6
|
||||||
self.assertEqual(self.i.destination(), 'base/01 02 03 04 5 6')
|
self.assertEqual(self.i.destination(), np('base/01 02 03 04 5 6'))
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class MoveTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_move_changes_path(self):
|
def test_move_changes_path(self):
|
||||||
self.i.move()
|
self.i.move()
|
||||||
self.assertEqual(self.i.path,self.dest)
|
self.assertEqual(self.i.path, beets.library._normpath(self.dest))
|
||||||
|
|
||||||
class DeleteTest(unittest.TestCase):
|
class DeleteTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue