Merge branch 'feature/expanduser-for-path-settings' into develop
This commit is contained in:
commit
2c117e8f15
0
bin/mopidy
Normal file → Executable file
0
bin/mopidy
Normal file → Executable file
@ -17,9 +17,9 @@ if __name__ == '__main__':
|
|||||||
def debug(uri, error):
|
def debug(uri, error):
|
||||||
print >> sys.stderr, 'Failed %s: %s' % (uri, error)
|
print >> sys.stderr, 'Failed %s: %s' % (uri, error)
|
||||||
|
|
||||||
print >> sys.stderr, 'Scanning %s' % settings.LOCAL_MUSIC_FOLDER
|
print >> sys.stderr, 'Scanning %s' % settings.LOCAL_MUSIC_PATH
|
||||||
|
|
||||||
scanner = Scanner(settings.LOCAL_MUSIC_FOLDER, store, debug)
|
scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug)
|
||||||
scanner.start()
|
scanner.start()
|
||||||
|
|
||||||
print >> sys.stderr, 'Done'
|
print >> sys.stderr, 'Done'
|
||||||
|
|||||||
@ -47,12 +47,12 @@ Generating a tag cache
|
|||||||
Previously the local storage backend relied purely on ``tag_cache`` files
|
Previously the local storage backend relied purely on ``tag_cache`` files
|
||||||
generated by the original MPD server. To remedy this the command
|
generated by the original MPD server. To remedy this the command
|
||||||
:command:`mopidy-scan` has been created. The program will scan your current
|
:command:`mopidy-scan` has been created. The program will scan your current
|
||||||
:attr:`mopidy.settings.LOCAL_MUSIC_FOLDER` and build a MPD compatible
|
:attr:`mopidy.settings.LOCAL_MUSIC_PATH` and build a MPD compatible
|
||||||
``tag_cache``.
|
``tag_cache``.
|
||||||
|
|
||||||
To make a ``tag_cache`` of your local music available for Mopidy:
|
To make a ``tag_cache`` of your local music available for Mopidy:
|
||||||
|
|
||||||
#. Ensure that :attr:`mopidy.settings.LOCAL_MUSIC_FOLDER` points to where your
|
#. Ensure that :attr:`mopidy.settings.LOCAL_MUSIC_PATH` points to where your
|
||||||
music is located. Check the current setting by running::
|
music is located. Check the current setting by running::
|
||||||
|
|
||||||
mopidy --list-settings
|
mopidy --list-settings
|
||||||
@ -64,7 +64,7 @@ To make a ``tag_cache`` of your local music available for Mopidy:
|
|||||||
mopidy-scan > tag_cache
|
mopidy-scan > tag_cache
|
||||||
|
|
||||||
#. Move the ``tag_cache`` file to the location
|
#. Move the ``tag_cache`` file to the location
|
||||||
:attr:`mopidy.settings.LOCAL_TAG_CACHE` is set to, or change the setting to
|
:attr:`mopidy.settings.LOCAL_TAG_CACHE_FILE` is set to, or change the setting to
|
||||||
point to where your ``tag_cache`` file is.
|
point to where your ``tag_cache`` file is.
|
||||||
|
|
||||||
#. Start Mopidy, find the music library in a client, and play some local music!
|
#. Start Mopidy, find the music library in a client, and play some local music!
|
||||||
|
|||||||
@ -18,7 +18,7 @@ class LibspotifyBackend(BaseBackend):
|
|||||||
|
|
||||||
**Settings:**
|
**Settings:**
|
||||||
|
|
||||||
- :attr:`mopidy.settings.SPOTIFY_LIB_CACHE`
|
- :attr:`mopidy.settings.SPOTIFY_CACHE_PATH`
|
||||||
- :attr:`mopidy.settings.SPOTIFY_USERNAME`
|
- :attr:`mopidy.settings.SPOTIFY_USERNAME`
|
||||||
- :attr:`mopidy.settings.SPOTIFY_PASSWORD`
|
- :attr:`mopidy.settings.SPOTIFY_PASSWORD`
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,8 @@ logger = logging.getLogger('mopidy.backends.libspotify.session_manager')
|
|||||||
# LibspotifySessionManager: Too many ancestors (9/7)
|
# LibspotifySessionManager: Too many ancestors (9/7)
|
||||||
|
|
||||||
class LibspotifySessionManager(SpotifySessionManager, BaseThread):
|
class LibspotifySessionManager(SpotifySessionManager, BaseThread):
|
||||||
cache_location = os.path.expanduser(settings.SPOTIFY_LIB_CACHE)
|
cache_location = settings.SPOTIFY_CACHE_PATH
|
||||||
settings_location = os.path.expanduser(settings.SPOTIFY_LIB_CACHE)
|
settings_location = settings.SPOTIFY_CACHE_PATH
|
||||||
appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key')
|
appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key')
|
||||||
user_agent = 'Mopidy %s' % get_version()
|
user_agent = 'Mopidy %s' % get_version()
|
||||||
|
|
||||||
|
|||||||
@ -23,9 +23,9 @@ class LocalBackend(BaseBackend):
|
|||||||
|
|
||||||
**Settings:**
|
**Settings:**
|
||||||
|
|
||||||
- :attr:`mopidy.settings.LOCAL_MUSIC_FOLDER`
|
- :attr:`mopidy.settings.LOCAL_MUSIC_PATH`
|
||||||
- :attr:`mopidy.settings.LOCAL_PLAYLIST_FOLDER`
|
- :attr:`mopidy.settings.LOCAL_PLAYLIST_PATH`
|
||||||
- :attr:`mopidy.settings.LOCAL_TAG_CACHE`
|
- :attr:`mopidy.settings.LOCAL_TAG_CACHE_FILE`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -66,7 +66,7 @@ class LocalPlaybackController(BasePlaybackController):
|
|||||||
class LocalStoredPlaylistsController(BaseStoredPlaylistsController):
|
class LocalStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super(LocalStoredPlaylistsController, self).__init__(*args)
|
super(LocalStoredPlaylistsController, self).__init__(*args)
|
||||||
self._folder = os.path.expanduser(settings.LOCAL_PLAYLIST_FOLDER)
|
self._folder = settings.LOCAL_PLAYLIST_PATH
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def lookup(self, uri):
|
def lookup(self, uri):
|
||||||
@ -143,8 +143,8 @@ class LocalLibraryController(BaseLibraryController):
|
|||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def refresh(self, uri=None):
|
def refresh(self, uri=None):
|
||||||
tag_cache = os.path.expanduser(settings.LOCAL_TAG_CACHE)
|
tag_cache = settings.LOCAL_TAG_CACHE_FILE
|
||||||
music_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER)
|
music_folder = settings.LOCAL_MUSIC_PATH
|
||||||
|
|
||||||
tracks = parse_mpd_tag_cache(tag_cache, music_folder)
|
tracks = parse_mpd_tag_cache(tag_cache, music_folder)
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ def tracks_to_tag_cache_format(tracks):
|
|||||||
def _add_to_tag_cache(result, folders, files):
|
def _add_to_tag_cache(result, folders, files):
|
||||||
for path, entry in folders.items():
|
for path, entry in folders.items():
|
||||||
name = os.path.split(path)[1]
|
name = os.path.split(path)[1]
|
||||||
music_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER)
|
music_folder = settings.LOCAL_MUSIC_PATH
|
||||||
mtime = get_mtime(os.path.join(music_folder, path))
|
mtime = get_mtime(os.path.join(music_folder, path))
|
||||||
result.append(('directory', path))
|
result.append(('directory', path))
|
||||||
result.append(('mtime', mtime))
|
result.append(('mtime', mtime))
|
||||||
@ -150,7 +150,7 @@ def tracks_to_directory_tree(tracks):
|
|||||||
path = u''
|
path = u''
|
||||||
current = directories
|
current = directories
|
||||||
|
|
||||||
local_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER)
|
local_folder = settings.LOCAL_MUSIC_PATH
|
||||||
track_path = uri_to_path(track.uri)
|
track_path = uri_to_path(track.uri)
|
||||||
track_path = re.sub('^' + re.escape(local_folder), '', track_path)
|
track_path = re.sub('^' + re.escape(local_folder), '', track_path)
|
||||||
track_dir = os.path.dirname(track_path)
|
track_dir = os.path.dirname(track_path)
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import pygst
|
|||||||
pygst.require('0.10')
|
pygst.require('0.10')
|
||||||
import gst
|
import gst
|
||||||
|
|
||||||
from os.path import abspath
|
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|||||||
@ -77,8 +77,8 @@ LASTFM_PASSWORD = u''
|
|||||||
#:
|
#:
|
||||||
#: Default::
|
#: Default::
|
||||||
#:
|
#:
|
||||||
#: LOCAL_MUSIC_FOLDER = u'~/music'
|
#: LOCAL_MUSIC_PATH = u'~/music'
|
||||||
LOCAL_MUSIC_FOLDER = u'~/music'
|
LOCAL_MUSIC_PATH = u'~/music'
|
||||||
|
|
||||||
#: Path to playlist folder with m3u files for local music.
|
#: Path to playlist folder with m3u files for local music.
|
||||||
#:
|
#:
|
||||||
@ -86,8 +86,8 @@ LOCAL_MUSIC_FOLDER = u'~/music'
|
|||||||
#:
|
#:
|
||||||
#: Default::
|
#: Default::
|
||||||
#:
|
#:
|
||||||
#: LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists'
|
#: LOCAL_PLAYLIST_PATH = u'~/.mopidy/playlists'
|
||||||
LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists'
|
LOCAL_PLAYLIST_PATH = u'~/.mopidy/playlists'
|
||||||
|
|
||||||
#: Path to tag cache for local music.
|
#: Path to tag cache for local music.
|
||||||
#:
|
#:
|
||||||
@ -95,8 +95,8 @@ LOCAL_PLAYLIST_FOLDER = u'~/.mopidy/playlists'
|
|||||||
#:
|
#:
|
||||||
#: Default::
|
#: Default::
|
||||||
#:
|
#:
|
||||||
#: LOCAL_TAG_CACHE = u'~/.mopidy/tag_cache'
|
#: LOCAL_TAG_CACHE_FILE = u'~/.mopidy/tag_cache'
|
||||||
LOCAL_TAG_CACHE = u'~/.mopidy/tag_cache'
|
LOCAL_TAG_CACHE_FILE = u'~/.mopidy/tag_cache'
|
||||||
|
|
||||||
#: Sound mixer to use. See :mod:`mopidy.mixers` for all available mixers.
|
#: Sound mixer to use. See :mod:`mopidy.mixers` for all available mixers.
|
||||||
#:
|
#:
|
||||||
@ -172,7 +172,7 @@ MPD_SERVER_PORT = 6600
|
|||||||
#: Path to the libspotify cache.
|
#: Path to the libspotify cache.
|
||||||
#:
|
#:
|
||||||
#: Used by :mod:`mopidy.backends.libspotify`.
|
#: Used by :mod:`mopidy.backends.libspotify`.
|
||||||
SPOTIFY_LIB_CACHE = u'~/.mopidy/libspotify_cache'
|
SPOTIFY_CACHE_PATH = u'~/.mopidy/libspotify_cache'
|
||||||
|
|
||||||
#: Your Spotify Premium username.
|
#: Your Spotify Premium username.
|
||||||
#:
|
#:
|
||||||
|
|||||||
@ -22,7 +22,6 @@ def get_or_create_file(filename):
|
|||||||
|
|
||||||
def path_to_uri(*paths):
|
def path_to_uri(*paths):
|
||||||
path = os.path.join(*paths)
|
path = os.path.join(*paths)
|
||||||
#path = os.path.expanduser(path) # FIXME Waiting for test case?
|
|
||||||
path = path.encode('utf-8')
|
path = path.encode('utf-8')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return 'file:' + urllib.pathname2url(path)
|
return 'file:' + urllib.pathname2url(path)
|
||||||
@ -46,16 +45,13 @@ def split_path(path):
|
|||||||
return parts
|
return parts
|
||||||
|
|
||||||
def find_files(path):
|
def find_files(path):
|
||||||
path = os.path.expanduser(path)
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
filename = os.path.abspath(path)
|
if not isinstance(path, unicode):
|
||||||
if not isinstance(filename, unicode):
|
path = path.decode('utf-8')
|
||||||
filename = filename.decode('utf-8')
|
yield path
|
||||||
yield filename
|
|
||||||
else:
|
else:
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
dirpath = os.path.abspath(dirpath)
|
|
||||||
filename = os.path.join(dirpath, filename)
|
filename = os.path.join(dirpath, filename)
|
||||||
if not isinstance(filename, unicode):
|
if not isinstance(filename, unicode):
|
||||||
filename = filename.decode('utf-8')
|
filename = filename.decode('utf-8')
|
||||||
|
|||||||
@ -51,6 +51,9 @@ class SettingsProxy(object):
|
|||||||
value = self.current[attr]
|
value = self.current[attr]
|
||||||
if type(value) != bool and not value:
|
if type(value) != bool and not value:
|
||||||
raise SettingsError(u'Setting "%s" is empty.' % attr)
|
raise SettingsError(u'Setting "%s" is empty.' % attr)
|
||||||
|
if attr.endswith('_PATH') or attr.endswith('_FILE'):
|
||||||
|
value = os.path.expanduser(value)
|
||||||
|
value = os.path.abspath(value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __setattr__(self, attr, value):
|
def __setattr__(self, attr, value):
|
||||||
@ -94,10 +97,14 @@ def validate_settings(defaults, settings):
|
|||||||
'DUMP_LOG_FILENAME': 'DEBUG_LOG_FILENAME',
|
'DUMP_LOG_FILENAME': 'DEBUG_LOG_FILENAME',
|
||||||
'DUMP_LOG_FORMAT': 'DEBUG_LOG_FORMAT',
|
'DUMP_LOG_FORMAT': 'DEBUG_LOG_FORMAT',
|
||||||
'FRONTEND': 'FRONTENDS',
|
'FRONTEND': 'FRONTENDS',
|
||||||
|
'LOCAL_MUSIC_FOLDER': 'LOCAL_MUSIC_PATH',
|
||||||
|
'LOCAL_PLAYLIST_FOLDER': 'LOCAL_PLAYLIST_PATH',
|
||||||
|
'LOCAL_TAG_CACHE': 'LOCAL_TAG_CACHE_FILE',
|
||||||
'SERVER': None,
|
'SERVER': None,
|
||||||
'SERVER_HOSTNAME': 'MPD_SERVER_HOSTNAME',
|
'SERVER_HOSTNAME': 'MPD_SERVER_HOSTNAME',
|
||||||
'SERVER_PORT': 'MPD_SERVER_PORT',
|
'SERVER_PORT': 'MPD_SERVER_PORT',
|
||||||
'SPOTIFY_LIB_APPKEY': None,
|
'SPOTIFY_LIB_APPKEY': None,
|
||||||
|
'SPOTIFY_LIB_CACHE': 'SPOTIFY_CACHE_PATH',
|
||||||
}
|
}
|
||||||
|
|
||||||
for setting, value in settings.iteritems():
|
for setting, value in settings.iteritems():
|
||||||
|
|||||||
@ -10,9 +10,9 @@ from tests import SkipTest, data_folder
|
|||||||
|
|
||||||
class BaseStoredPlaylistsControllerTest(object):
|
class BaseStoredPlaylistsControllerTest(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.LOCAL_PLAYLIST_FOLDER = tempfile.mkdtemp()
|
settings.LOCAL_PLAYLIST_PATH = tempfile.mkdtemp()
|
||||||
settings.LOCAL_TAG_CACHE = data_folder('library_tag_cache')
|
settings.LOCAL_TAG_CACHE_FILE = data_folder('library_tag_cache')
|
||||||
settings.LOCAL_MUSIC_FOLDER = data_folder('')
|
settings.LOCAL_MUSIC_PATH = data_folder('')
|
||||||
|
|
||||||
self.backend = self.backend_class(mixer_class=DummyMixer)
|
self.backend = self.backend_class(mixer_class=DummyMixer)
|
||||||
self.stored = self.backend.stored_playlists
|
self.stored = self.backend.stored_playlists
|
||||||
@ -20,8 +20,8 @@ class BaseStoredPlaylistsControllerTest(object):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.backend.destroy()
|
self.backend.destroy()
|
||||||
|
|
||||||
if os.path.exists(settings.LOCAL_PLAYLIST_FOLDER):
|
if os.path.exists(settings.LOCAL_PLAYLIST_PATH):
|
||||||
shutil.rmtree(settings.LOCAL_PLAYLIST_FOLDER)
|
shutil.rmtree(settings.LOCAL_PLAYLIST_PATH)
|
||||||
|
|
||||||
settings.runtime.clear()
|
settings.runtime.clear()
|
||||||
|
|
||||||
|
|||||||
@ -17,8 +17,8 @@ class LocalLibraryControllerTest(BaseLibraryControllerTest, unittest.TestCase):
|
|||||||
backend_class = LocalBackend
|
backend_class = LocalBackend
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.LOCAL_TAG_CACHE = data_folder('library_tag_cache')
|
settings.LOCAL_TAG_CACHE_FILE = data_folder('library_tag_cache')
|
||||||
settings.LOCAL_MUSIC_FOLDER = data_folder('')
|
settings.LOCAL_MUSIC_PATH = data_folder('')
|
||||||
|
|
||||||
super(LocalLibraryControllerTest, self).setUp()
|
super(LocalLibraryControllerTest, self).setUp()
|
||||||
|
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest,
|
|||||||
backend_class = LocalBackend
|
backend_class = LocalBackend
|
||||||
|
|
||||||
def test_created_playlist_is_persisted(self):
|
def test_created_playlist_is_persisted(self):
|
||||||
path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u')
|
path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u')
|
||||||
self.assert_(not os.path.exists(path))
|
self.assert_(not os.path.exists(path))
|
||||||
self.stored.create('test')
|
self.stored.create('test')
|
||||||
self.assert_(os.path.exists(path))
|
self.assert_(os.path.exists(path))
|
||||||
|
|
||||||
def test_saved_playlist_is_persisted(self):
|
def test_saved_playlist_is_persisted(self):
|
||||||
path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test2.m3u')
|
path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test2.m3u')
|
||||||
self.assert_(not os.path.exists(path))
|
self.assert_(not os.path.exists(path))
|
||||||
self.stored.save(Playlist(name='test2'))
|
self.stored.save(Playlist(name='test2'))
|
||||||
self.assert_(os.path.exists(path))
|
self.assert_(os.path.exists(path))
|
||||||
@ -39,13 +39,13 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest,
|
|||||||
def test_deleted_playlist_get_removed(self):
|
def test_deleted_playlist_get_removed(self):
|
||||||
playlist = self.stored.create('test')
|
playlist = self.stored.create('test')
|
||||||
self.stored.delete(playlist)
|
self.stored.delete(playlist)
|
||||||
path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u')
|
path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u')
|
||||||
self.assert_(not os.path.exists(path))
|
self.assert_(not os.path.exists(path))
|
||||||
|
|
||||||
def test_renamed_playlist_gets_moved(self):
|
def test_renamed_playlist_gets_moved(self):
|
||||||
playlist = self.stored.create('test')
|
playlist = self.stored.create('test')
|
||||||
file1 = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u')
|
file1 = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u')
|
||||||
file2 = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test2.m3u')
|
file2 = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test2.m3u')
|
||||||
self.assert_(not os.path.exists(file2))
|
self.assert_(not os.path.exists(file2))
|
||||||
self.stored.rename(playlist, 'test2')
|
self.stored.rename(playlist, 'test2')
|
||||||
self.assert_(not os.path.exists(file1))
|
self.assert_(not os.path.exists(file1))
|
||||||
@ -55,7 +55,7 @@ class LocalStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest,
|
|||||||
track = Track(uri=generate_song(1))
|
track = Track(uri=generate_song(1))
|
||||||
uri = track.uri[len('file://'):]
|
uri = track.uri[len('file://'):]
|
||||||
playlist = Playlist(tracks=[track], name='test')
|
playlist = Playlist(tracks=[track], name='test')
|
||||||
path = os.path.join(settings.LOCAL_PLAYLIST_FOLDER, 'test.m3u')
|
path = os.path.join(settings.LOCAL_PLAYLIST_PATH, 'test.m3u')
|
||||||
|
|
||||||
self.stored.save(playlist)
|
self.stored.save(playlist)
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from tests import data_folder, SkipTest
|
|||||||
|
|
||||||
class TrackMpdFormatTest(unittest.TestCase):
|
class TrackMpdFormatTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.LOCAL_MUSIC_FOLDER = '/dir/subdir'
|
settings.LOCAL_MUSIC_PATH = '/dir/subdir'
|
||||||
mtime.set_fake_time(1234567)
|
mtime.set_fake_time(1234567)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -104,7 +104,7 @@ class PlaylistMpdFormatTest(unittest.TestCase):
|
|||||||
|
|
||||||
class TracksToTagCacheFormatTest(unittest.TestCase):
|
class TracksToTagCacheFormatTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.LOCAL_MUSIC_FOLDER = '/dir/subdir'
|
settings.LOCAL_MUSIC_PATH = '/dir/subdir'
|
||||||
mtime.set_fake_time(1234567)
|
mtime.set_fake_time(1234567)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -279,7 +279,7 @@ class TracksToTagCacheFormatTest(unittest.TestCase):
|
|||||||
|
|
||||||
class TracksToDirectoryTreeTest(unittest.TestCase):
|
class TracksToDirectoryTreeTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.LOCAL_MUSIC_FOLDER = '/root/'
|
settings.LOCAL_MUSIC_PATH = '/root/'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
settings.runtime.clear()
|
settings.runtime.clear()
|
||||||
|
|||||||
@ -34,9 +34,6 @@ class GetOrCreateFolderTest(unittest.TestCase):
|
|||||||
self.assert_(os.path.isdir(self.parent))
|
self.assert_(os.path.isdir(self.parent))
|
||||||
self.assertEqual(created, self.parent)
|
self.assertEqual(created, self.parent)
|
||||||
|
|
||||||
def test_that_userfolder_is_expanded(self):
|
|
||||||
raise SkipTest # Not sure how to safely test this
|
|
||||||
|
|
||||||
|
|
||||||
class PathToFileURITest(unittest.TestCase):
|
class PathToFileURITest(unittest.TestCase):
|
||||||
def test_simple_path(self):
|
def test_simple_path(self):
|
||||||
@ -139,9 +136,6 @@ class FindFilesTest(unittest.TestCase):
|
|||||||
self.assert_(is_unicode(name),
|
self.assert_(is_unicode(name),
|
||||||
'%s is not unicode object' % repr(name))
|
'%s is not unicode object' % repr(name))
|
||||||
|
|
||||||
def test_expanduser(self):
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
|
|
||||||
class MtimeTest(unittest.TestCase):
|
class MtimeTest(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mopidy import settings as default_settings_module
|
from mopidy import settings as default_settings_module
|
||||||
@ -65,3 +66,37 @@ class SettingsProxyTest(unittest.TestCase):
|
|||||||
def test_runtime_value_included_in_current(self):
|
def test_runtime_value_included_in_current(self):
|
||||||
self.settings.TEST = 'test'
|
self.settings.TEST = 'test'
|
||||||
self.assertEqual(self.settings.current['TEST'], 'test')
|
self.assertEqual(self.settings.current['TEST'], 'test')
|
||||||
|
|
||||||
|
def test_value_ending_in_path_is_expanded(self):
|
||||||
|
self.settings.TEST_PATH = '~/test'
|
||||||
|
acctual = self.settings.TEST_PATH
|
||||||
|
expected = os.path.expanduser('~/test')
|
||||||
|
self.assertEqual(acctual, expected)
|
||||||
|
|
||||||
|
def test_value_ending_in_path_is_absolute(self):
|
||||||
|
self.settings.TEST_PATH = './test'
|
||||||
|
acctual = self.settings.TEST_PATH
|
||||||
|
expected = os.path.abspath('./test')
|
||||||
|
self.assertEqual(acctual, expected)
|
||||||
|
|
||||||
|
def test_value_ending_in_file_is_expanded(self):
|
||||||
|
self.settings.TEST_FILE = '~/test'
|
||||||
|
acctual = self.settings.TEST_FILE
|
||||||
|
expected = os.path.expanduser('~/test')
|
||||||
|
self.assertEqual(acctual, expected)
|
||||||
|
|
||||||
|
def test_value_ending_in_file_is_absolute(self):
|
||||||
|
self.settings.TEST_FILE = './test'
|
||||||
|
acctual = self.settings.TEST_FILE
|
||||||
|
expected = os.path.abspath('./test')
|
||||||
|
self.assertEqual(acctual, expected)
|
||||||
|
|
||||||
|
def test_value_not_ending_in_path_or_file_is_not_expanded(self):
|
||||||
|
self.settings.TEST = '~/test'
|
||||||
|
acctual = self.settings.TEST
|
||||||
|
self.assertEqual(acctual, '~/test')
|
||||||
|
|
||||||
|
def test_value_not_ending_in_path_or_file_is_not_absolute(self):
|
||||||
|
self.settings.TEST = './test'
|
||||||
|
acctual = self.settings.TEST
|
||||||
|
self.assertEqual(acctual, './test')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user