Merge pull request #130 from adamcik/feature/unittest2-fallback
This commit is contained in:
commit
aa8f60fb86
@ -60,6 +60,7 @@ def find_files(path):
|
|||||||
yield filename
|
yield filename
|
||||||
# pylint: enable = W0612
|
# pylint: enable = W0612
|
||||||
|
|
||||||
|
# FIXME replace with mock usage in tests.
|
||||||
class Mtime(object):
|
class Mtime(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fake = None
|
self.fake = None
|
||||||
|
|||||||
@ -1,27 +1,24 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
try: # 2.7
|
if sys.version_info < (2, 7):
|
||||||
# pylint: disable = E0611,F0401
|
import unittest2 as unittest
|
||||||
from unittest.case import SkipTest
|
else:
|
||||||
# pylint: enable = E0611,F0401
|
import unittest
|
||||||
except ImportError:
|
|
||||||
try: # Nose
|
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
except ImportError: # Failsafe
|
|
||||||
class SkipTest(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
|
|
||||||
# Nuke any local settings to ensure same test env all over
|
# Nuke any local settings to ensure same test env all over
|
||||||
settings.local.clear()
|
settings.local.clear()
|
||||||
|
|
||||||
|
|
||||||
def path_to_data_dir(name):
|
def path_to_data_dir(name):
|
||||||
path = os.path.dirname(__file__)
|
path = os.path.dirname(__file__)
|
||||||
path = os.path.join(path, 'data')
|
path = os.path.join(path, 'data')
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
return os.path.join(path, name)
|
return os.path.join(path, name)
|
||||||
|
|
||||||
|
|
||||||
class IsA(object):
|
class IsA(object):
|
||||||
def __init__(self, klass):
|
def __init__(self, klass):
|
||||||
self.klass = klass
|
self.klass = klass
|
||||||
@ -38,6 +35,7 @@ class IsA(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self.klass)
|
return str(self.klass)
|
||||||
|
|
||||||
|
|
||||||
any_int = IsA(int)
|
any_int = IsA(int)
|
||||||
any_str = IsA(str)
|
any_str = IsA(str)
|
||||||
any_unicode = IsA(unicode)
|
any_unicode = IsA(unicode)
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import mock
|
import mock
|
||||||
import multiprocessing
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from mopidy.models import Playlist, Track
|
from mopidy.models import Playlist, Track
|
||||||
@ -7,6 +6,7 @@ from mopidy.gstreamer import GStreamer
|
|||||||
|
|
||||||
from tests.backends.base import populate_playlist
|
from tests.backends.base import populate_playlist
|
||||||
|
|
||||||
|
|
||||||
class CurrentPlaylistControllerTest(object):
|
class CurrentPlaylistControllerTest(object):
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from mopidy.models import Playlist, Track, Album, Artist
|
from mopidy.models import Playlist, Track, Album, Artist
|
||||||
|
|
||||||
from tests import SkipTest, path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
|
|
||||||
class LibraryControllerTest(object):
|
class LibraryControllerTest(object):
|
||||||
artists = [Artist(name='artist1'), Artist(name='artist2'), Artist()]
|
artists = [Artist(name='artist1'), Artist(name='artist2'), Artist()]
|
||||||
@ -20,11 +21,13 @@ class LibraryControllerTest(object):
|
|||||||
def test_refresh(self):
|
def test_refresh(self):
|
||||||
self.library.refresh()
|
self.library.refresh()
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_refresh_uri(self):
|
def test_refresh_uri(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_refresh_missing_uri(self):
|
def test_refresh_missing_uri(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
def test_lookup(self):
|
def test_lookup(self):
|
||||||
track = self.library.lookup(self.tracks[0].uri)
|
track = self.library.lookup(self.tracks[0].uri)
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
import mock
|
import mock
|
||||||
import multiprocessing
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.gstreamer import GStreamer
|
from mopidy.gstreamer import GStreamer
|
||||||
|
|
||||||
from tests import SkipTest
|
from tests import unittest
|
||||||
from tests.backends.base import populate_playlist
|
from tests.backends.base import populate_playlist
|
||||||
|
|
||||||
# TODO Test 'playlist repeat', e.g. repeat=1,single=0
|
# TODO Test 'playlist repeat', e.g. repeat=1,single=0
|
||||||
|
|
||||||
|
|
||||||
class PlaybackControllerTest(object):
|
class PlaybackControllerTest(object):
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ class PlaybackControllerTest(object):
|
|||||||
|
|
||||||
self.assert_(wrapper.called)
|
self.assert_(wrapper.called)
|
||||||
|
|
||||||
@SkipTest # Blocks for 10ms
|
@unittest.SkipTest # Blocks for 10ms
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_end_of_track_callback_gets_called(self):
|
def test_end_of_track_callback_gets_called(self):
|
||||||
self.playback.play()
|
self.playback.play()
|
||||||
@ -599,7 +599,7 @@ class PlaybackControllerTest(object):
|
|||||||
self.playback.pause()
|
self.playback.pause()
|
||||||
self.assertEqual(self.playback.resume(), None)
|
self.assertEqual(self.playback.resume(), None)
|
||||||
|
|
||||||
@SkipTest # Uses sleep and might not work with LocalBackend
|
@unittest.SkipTest # Uses sleep and might not work with LocalBackend
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_resume_continues_from_right_position(self):
|
def test_resume_continues_from_right_position(self):
|
||||||
self.playback.play()
|
self.playback.play()
|
||||||
@ -668,7 +668,7 @@ class PlaybackControllerTest(object):
|
|||||||
self.playback.seek(0)
|
self.playback.seek(0)
|
||||||
self.assertEqual(self.playback.state, self.playback.PLAYING)
|
self.assertEqual(self.playback.state, self.playback.PLAYING)
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_seek_beyond_end_of_song(self):
|
def test_seek_beyond_end_of_song(self):
|
||||||
# FIXME need to decide return value
|
# FIXME need to decide return value
|
||||||
@ -688,7 +688,7 @@ class PlaybackControllerTest(object):
|
|||||||
self.playback.seek(self.current_playlist.tracks[-1].length * 100)
|
self.playback.seek(self.current_playlist.tracks[-1].length * 100)
|
||||||
self.assertEqual(self.playback.state, self.playback.STOPPED)
|
self.assertEqual(self.playback.state, self.playback.STOPPED)
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_seek_beyond_start_of_song(self):
|
def test_seek_beyond_start_of_song(self):
|
||||||
# FIXME need to decide return value
|
# FIXME need to decide return value
|
||||||
@ -741,7 +741,7 @@ class PlaybackControllerTest(object):
|
|||||||
|
|
||||||
self.assertEqual(self.playback.time_position, 0)
|
self.assertEqual(self.playback.time_position, 0)
|
||||||
|
|
||||||
@SkipTest # Uses sleep and does might not work with LocalBackend
|
@unittest.SkipTest # Uses sleep and does might not work with LocalBackend
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_time_position_when_playing(self):
|
def test_time_position_when_playing(self):
|
||||||
self.playback.play()
|
self.playback.play()
|
||||||
@ -750,7 +750,7 @@ class PlaybackControllerTest(object):
|
|||||||
second = self.playback.time_position
|
second = self.playback.time_position
|
||||||
self.assert_(second > first, '%s - %s' % (first, second))
|
self.assert_(second > first, '%s - %s' % (first, second))
|
||||||
|
|
||||||
@SkipTest # Uses sleep
|
@unittest.SkipTest # Uses sleep
|
||||||
@populate_playlist
|
@populate_playlist
|
||||||
def test_time_position_when_paused(self):
|
def test_time_position_when_paused(self):
|
||||||
self.playback.play()
|
self.playback.play()
|
||||||
|
|||||||
@ -5,7 +5,8 @@ import tempfile
|
|||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.models import Playlist
|
from mopidy.models import Playlist
|
||||||
|
|
||||||
from tests import SkipTest, path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
|
|
||||||
class StoredPlaylistsControllerTest(object):
|
class StoredPlaylistsControllerTest(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -78,11 +79,13 @@ class StoredPlaylistsControllerTest(object):
|
|||||||
except LookupError as e:
|
except LookupError as e:
|
||||||
self.assertEqual(u'"name=c" match no playlists', e[0])
|
self.assertEqual(u'"name=c" match no playlists', e[0])
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_lookup(self):
|
def test_lookup(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_refresh(self):
|
def test_refresh(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
def test_rename(self):
|
def test_rename(self):
|
||||||
playlist = self.stored.create('test')
|
playlist = self.stored.create('test')
|
||||||
@ -100,5 +103,6 @@ class StoredPlaylistsControllerTest(object):
|
|||||||
self.stored.save(playlist)
|
self.stored.save(playlist)
|
||||||
self.assert_(playlist in self.stored.playlists)
|
self.assert_(playlist in self.stored.playlists)
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_playlist_with_unknown_track(self):
|
def test_playlist_with_unknown_track(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import mock
|
import mock
|
||||||
import unittest
|
|
||||||
|
|
||||||
from pykka.registry import ActorRegistry
|
from pykka.registry import ActorRegistry
|
||||||
|
|
||||||
@ -7,6 +6,9 @@ from mopidy.backends.dummy import DummyBackend
|
|||||||
from mopidy.listeners import BackendListener
|
from mopidy.listeners import BackendListener
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(BackendListener, 'send')
|
@mock.patch.object(BackendListener, 'send')
|
||||||
class BackendEventsTest(unittest.TestCase):
|
class BackendEventsTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
# FIXME Our Windows build server does not support GStreamer yet
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'win32':
|
|
||||||
from tests import SkipTest
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.local import LocalBackend
|
from mopidy.backends.local import LocalBackend
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
from tests.backends.base.current_playlist import CurrentPlaylistControllerTest
|
from tests.backends.base.current_playlist import CurrentPlaylistControllerTest
|
||||||
from tests.backends.local import generate_song
|
from tests.backends.local import generate_song
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32',
|
||||||
|
'Our Windows build server does not support GStreamer yet')
|
||||||
class LocalCurrentPlaylistControllerTest(CurrentPlaylistControllerTest,
|
class LocalCurrentPlaylistControllerTest(CurrentPlaylistControllerTest,
|
||||||
unittest.TestCase):
|
unittest.TestCase):
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
# FIXME Our Windows build server does not support GStreamer yet
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'win32':
|
|
||||||
from tests import SkipTest
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.local import LocalBackend
|
from mopidy.backends.local import LocalBackend
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
from tests.backends.base.library import LibraryControllerTest
|
from tests.backends.base.library import LibraryControllerTest
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32',
|
||||||
|
'Our Windows build server does not support GStreamer yet')
|
||||||
class LocalLibraryControllerTest(LibraryControllerTest, unittest.TestCase):
|
class LocalLibraryControllerTest(LibraryControllerTest, unittest.TestCase):
|
||||||
|
|
||||||
backend_class = LocalBackend
|
backend_class = LocalBackend
|
||||||
|
|||||||
@ -1,20 +1,17 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
# FIXME Our Windows build server does not support GStreamer yet
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'win32':
|
|
||||||
from tests import SkipTest
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.local import LocalBackend
|
from mopidy.backends.local import LocalBackend
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
from mopidy.utils.path import path_to_uri
|
from mopidy.utils.path import path_to_uri
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
from tests.backends.base.playback import PlaybackControllerTest
|
from tests.backends.base.playback import PlaybackControllerTest
|
||||||
from tests.backends.local import generate_song
|
from tests.backends.local import generate_song
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32',
|
||||||
|
'Our Windows build server does not support GStreamer yet')
|
||||||
class LocalPlaybackControllerTest(PlaybackControllerTest, unittest.TestCase):
|
class LocalPlaybackControllerTest(PlaybackControllerTest, unittest.TestCase):
|
||||||
backend_class = LocalBackend
|
backend_class = LocalBackend
|
||||||
tracks = [Track(uri=generate_song(i), length=4464)
|
tracks = [Track(uri=generate_song(i), length=4464)
|
||||||
|
|||||||
@ -1,24 +1,19 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tests import SkipTest
|
|
||||||
|
|
||||||
# FIXME Our Windows build server does not support GStreamer yet
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'win32':
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.local import LocalBackend
|
from mopidy.backends.local import LocalBackend
|
||||||
from mopidy.mixers.dummy import DummyMixer
|
|
||||||
from mopidy.models import Playlist, Track
|
from mopidy.models import Playlist, Track
|
||||||
from mopidy.utils.path import path_to_uri
|
from mopidy.utils.path import path_to_uri
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
from tests.backends.base.stored_playlists import \
|
from tests.backends.base.stored_playlists import (
|
||||||
StoredPlaylistsControllerTest
|
StoredPlaylistsControllerTest)
|
||||||
from tests.backends.local import generate_song
|
from tests.backends.local import generate_song
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32',
|
||||||
|
'Our Windows build server does not support GStreamer yet')
|
||||||
class LocalStoredPlaylistsControllerTest(StoredPlaylistsControllerTest,
|
class LocalStoredPlaylistsControllerTest(StoredPlaylistsControllerTest,
|
||||||
unittest.TestCase):
|
unittest.TestCase):
|
||||||
|
|
||||||
@ -77,14 +72,18 @@ class LocalStoredPlaylistsControllerTest(StoredPlaylistsControllerTest,
|
|||||||
self.assertEqual('test', self.stored.playlists[0].name)
|
self.assertEqual('test', self.stored.playlists[0].name)
|
||||||
self.assertEqual(track.uri, self.stored.playlists[0].tracks[0].uri)
|
self.assertEqual(track.uri, self.stored.playlists[0].tracks[0].uri)
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_santitising_of_playlist_filenames(self):
|
def test_santitising_of_playlist_filenames(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_playlist_folder_is_createad(self):
|
def test_playlist_folder_is_createad(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_create_sets_playlist_uri(self):
|
def test_create_sets_playlist_uri(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_save_sets_playlist_uri(self):
|
def test_save_sets_playlist_uri(self):
|
||||||
raise SkipTest
|
pass
|
||||||
|
|||||||
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.utils.path import path_to_uri
|
from mopidy.utils.path import path_to_uri
|
||||||
from mopidy.backends.local.translator import parse_m3u, parse_mpd_tag_cache
|
from mopidy.backends.local.translator import parse_m3u, parse_mpd_tag_cache
|
||||||
from mopidy.models import Track, Artist, Album
|
from mopidy.models import Track, Artist, Album
|
||||||
|
|
||||||
from tests import SkipTest, path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
song1_path = path_to_data_dir('song1.mp3')
|
song1_path = path_to_data_dir('song1.mp3')
|
||||||
song2_path = path_to_data_dir('song2.mp3')
|
song2_path = path_to_data_dir('song2.mp3')
|
||||||
@ -17,6 +16,9 @@ song1_uri = path_to_uri(song1_path)
|
|||||||
song2_uri = path_to_uri(song2_path)
|
song2_uri = path_to_uri(song2_path)
|
||||||
encoded_uri = path_to_uri(encoded_path)
|
encoded_uri = path_to_uri(encoded_path)
|
||||||
|
|
||||||
|
# FIXME use mock instead of tempfile.NamedTemporaryFile
|
||||||
|
|
||||||
|
|
||||||
class M3UToUriTest(unittest.TestCase):
|
class M3UToUriTest(unittest.TestCase):
|
||||||
def test_empty_file(self):
|
def test_empty_file(self):
|
||||||
uris = parse_m3u(path_to_data_dir('empty.m3u'))
|
uris = parse_m3u(path_to_data_dir('empty.m3u'))
|
||||||
@ -127,9 +129,10 @@ class MPDTagCacheToTracksTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(track, list(tracks)[0])
|
self.assertEqual(track, list(tracks)[0])
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_misencoded_cache(self):
|
def test_misencoded_cache(self):
|
||||||
# FIXME not sure if this can happen
|
# FIXME not sure if this can happen
|
||||||
raise SkipTest
|
pass
|
||||||
|
|
||||||
def test_cache_with_blank_track_info(self):
|
def test_cache_with_blank_track_info(self):
|
||||||
tracks = parse_mpd_tag_cache(path_to_data_dir('blank_tag_cache'),
|
tracks = parse_mpd_tag_cache(path_to_data_dir('blank_tag_cache'),
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.backends.dummy import DummyBackend
|
from mopidy.backends.dummy import DummyBackend
|
||||||
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
|
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
|
||||||
from mopidy.frontends.mpd.exceptions import MpdAckError
|
from mopidy.frontends.mpd.exceptions import MpdAckError
|
||||||
from mopidy.frontends.mpd.protocol import request_handlers, handle_request
|
from mopidy.frontends.mpd.protocol import request_handlers, handle_request
|
||||||
from mopidy.mixers.dummy import DummyMixer
|
from mopidy.mixers.dummy import DummyMixer
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class MpdDispatcherTest(unittest.TestCase):
|
class MpdDispatcherTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.backend = DummyBackend.start().proxy()
|
self.backend = DummyBackend.start().proxy()
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdPermissionError,
|
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdPermissionError,
|
||||||
MpdUnknownCommand, MpdSystemError, MpdNotImplemented)
|
MpdUnknownCommand, MpdSystemError, MpdNotImplemented)
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class MpdExceptionsTest(unittest.TestCase):
|
class MpdExceptionsTest(unittest.TestCase):
|
||||||
def test_key_error_wrapped_in_mpd_ack_error(self):
|
def test_key_error_wrapped_in_mpd_ack_error(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import unittest
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
@ -6,6 +5,8 @@ from mopidy.backends import dummy as backend
|
|||||||
from mopidy.frontends import mpd
|
from mopidy.frontends import mpd
|
||||||
from mopidy.mixers import dummy as mixer
|
from mopidy.mixers import dummy as mixer
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class MockConnetion(mock.Mock):
|
class MockConnetion(mock.Mock):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class AudioOutputHandlerTest(protocol.BaseTestCase):
|
class AudioOutputHandlerTest(protocol.BaseTestCase):
|
||||||
def test_enableoutput(self):
|
def test_enableoutput(self):
|
||||||
self.sendRequest(u'enableoutput "0"')
|
self.sendRequest(u'enableoutput "0"')
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from mopidy import settings
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationTest(protocol.BaseTestCase):
|
class AuthenticationTest(protocol.BaseTestCase):
|
||||||
def test_authentication_with_valid_password_is_accepted(self):
|
def test_authentication_with_valid_password_is_accepted(self):
|
||||||
settings.MPD_SERVER_PASSWORD = u'topsecret'
|
settings.MPD_SERVER_PASSWORD = u'topsecret'
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class CommandListsTest(protocol.BaseTestCase):
|
class CommandListsTest(protocol.BaseTestCase):
|
||||||
def test_command_list_begin(self):
|
def test_command_list_begin(self):
|
||||||
response = self.sendRequest(u'command_list_begin')
|
response = self.sendRequest(u'command_list_begin')
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from mopidy import settings
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class ConnectionHandlerTest(protocol.BaseTestCase):
|
class ConnectionHandlerTest(protocol.BaseTestCase):
|
||||||
def test_close_closes_the_client_connection(self):
|
def test_close_closes_the_client_connection(self):
|
||||||
with patch.object(self.session, 'close') as close_mock:
|
with patch.object(self.session, 'close') as close_mock:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from mopidy.models import Track
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
|
class CurrentPlaylistHandlerTest(protocol.BaseTestCase):
|
||||||
def test_add(self):
|
def test_add(self):
|
||||||
needle = Track(uri='dummy://foo')
|
needle = Track(uri='dummy://foo')
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from mopidy.frontends.mpd.protocol.status import SUBSYSTEMS
|
from mopidy.frontends.mpd.protocol.status import SUBSYSTEMS
|
||||||
from mopidy.models import Track
|
|
||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class IdleHandlerTest(protocol.BaseTestCase):
|
class IdleHandlerTest(protocol.BaseTestCase):
|
||||||
def idleEvent(self, subsystem):
|
def idleEvent(self, subsystem):
|
||||||
self.session.on_idle(subsystem)
|
self.session.on_idle(subsystem)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class MusicDatabaseHandlerTest(protocol.BaseTestCase):
|
class MusicDatabaseHandlerTest(protocol.BaseTestCase):
|
||||||
def test_count(self):
|
def test_count(self):
|
||||||
self.sendRequest(u'count "tag" "needle"')
|
self.sendRequest(u'count "tag" "needle"')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from mopidy.backends import base as backend
|
from mopidy.backends import base as backend
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
from tests import SkipTest
|
from tests import unittest
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
PAUSED = backend.PlaybackController.PAUSED
|
PAUSED = backend.PlaybackController.PAUSED
|
||||||
@ -146,14 +146,17 @@ class PlaybackOptionsHandlerTest(protocol.BaseTestCase):
|
|||||||
self.assertInResponse(u'OK')
|
self.assertInResponse(u'OK')
|
||||||
self.assertInResponse(u'off')
|
self.assertInResponse(u'off')
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_replay_gain_status_off(self):
|
def test_replay_gain_status_off(self):
|
||||||
raise SkipTest # TODO
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_replay_gain_status_track(self):
|
def test_replay_gain_status_track(self):
|
||||||
raise SkipTest # TODO
|
pass
|
||||||
|
|
||||||
|
@unittest.SkipTest
|
||||||
def test_replay_gain_status_album(self):
|
def test_replay_gain_status_album(self):
|
||||||
raise SkipTest # TODO
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PlaybackControlHandlerTest(protocol.BaseTestCase):
|
class PlaybackControlHandlerTest(protocol.BaseTestCase):
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from mopidy import settings
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class ReflectionHandlerTest(protocol.BaseTestCase):
|
class ReflectionHandlerTest(protocol.BaseTestCase):
|
||||||
def test_commands_returns_list_of_all_commands(self):
|
def test_commands_returns_list_of_all_commands(self):
|
||||||
self.sendRequest(u'commands')
|
self.sendRequest(u'commands')
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from mopidy.models import Track
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class IssueGH17RegressionTest(protocol.BaseTestCase):
|
class IssueGH17RegressionTest(protocol.BaseTestCase):
|
||||||
"""
|
"""
|
||||||
The issue: http://github.com/mopidy/mopidy/issues#issue/17
|
The issue: http://github.com/mopidy/mopidy/issues#issue/17
|
||||||
|
|||||||
@ -2,6 +2,7 @@ from mopidy.models import Track
|
|||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class StatusHandlerTest(protocol.BaseTestCase):
|
class StatusHandlerTest(protocol.BaseTestCase):
|
||||||
def test_clearerror(self):
|
def test_clearerror(self):
|
||||||
self.sendRequest(u'clearerror')
|
self.sendRequest(u'clearerror')
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class StickersHandlerTest(protocol.BaseTestCase):
|
class StickersHandlerTest(protocol.BaseTestCase):
|
||||||
def test_sticker_get(self):
|
def test_sticker_get(self):
|
||||||
self.sendRequest(
|
self.sendRequest(
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import datetime as dt
|
import datetime
|
||||||
|
|
||||||
from mopidy.models import Track, Playlist
|
from mopidy.models import Track, Playlist
|
||||||
|
|
||||||
from tests.frontends.mpd import protocol
|
from tests.frontends.mpd import protocol
|
||||||
|
|
||||||
|
|
||||||
class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
||||||
def test_listplaylist(self):
|
def test_listplaylist(self):
|
||||||
self.backend.stored_playlists.playlists = [
|
self.backend.stored_playlists.playlists = [
|
||||||
@ -33,7 +34,7 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
|
|||||||
u'ACK [50@0] {listplaylistinfo} No such playlist')
|
u'ACK [50@0] {listplaylistinfo} No such playlist')
|
||||||
|
|
||||||
def test_listplaylists(self):
|
def test_listplaylists(self):
|
||||||
last_modified = dt.datetime(2001, 3, 17, 13, 41, 17, 12345)
|
last_modified = datetime.datetime(2001, 3, 17, 13, 41, 17, 12345)
|
||||||
self.backend.stored_playlists.playlists = [Playlist(name='a',
|
self.backend.stored_playlists.playlists = [Playlist(name='a',
|
||||||
last_modified=last_modified)]
|
last_modified=last_modified)]
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
import datetime as dt
|
import datetime
|
||||||
import os
|
import os
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.utils.path import mtime, uri_to_path
|
from mopidy.utils.path import mtime, uri_to_path
|
||||||
from mopidy.frontends.mpd import translator, protocol
|
from mopidy.frontends.mpd import translator, protocol
|
||||||
from mopidy.models import Album, Artist, Playlist, Track
|
from mopidy.models import Album, Artist, Playlist, Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class TrackMpdFormatTest(unittest.TestCase):
|
class TrackMpdFormatTest(unittest.TestCase):
|
||||||
track = Track(
|
track = Track(
|
||||||
uri=u'a uri',
|
uri=u'a uri',
|
||||||
@ -15,7 +17,7 @@ class TrackMpdFormatTest(unittest.TestCase):
|
|||||||
album=Album(name=u'an album', num_tracks=13,
|
album=Album(name=u'an album', num_tracks=13,
|
||||||
artists=[Artist(name=u'an other artist')]),
|
artists=[Artist(name=u'an other artist')]),
|
||||||
track_no=7,
|
track_no=7,
|
||||||
date=dt.date(1977, 1, 1),
|
date=datetime.date(1977, 1, 1),
|
||||||
length=137000,
|
length=137000,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ class TrackMpdFormatTest(unittest.TestCase):
|
|||||||
self.assert_(('Album', 'an album') in result)
|
self.assert_(('Album', 'an album') in result)
|
||||||
self.assert_(('AlbumArtist', 'an other artist') in result)
|
self.assert_(('AlbumArtist', 'an other artist') in result)
|
||||||
self.assert_(('Track', '7/13') in result)
|
self.assert_(('Track', '7/13') in result)
|
||||||
self.assert_(('Date', dt.date(1977, 1, 1)) in result)
|
self.assert_(('Date', datetime.date(1977, 1, 1)) in result)
|
||||||
self.assert_(('Pos', 9) in result)
|
self.assert_(('Pos', 9) in result)
|
||||||
self.assert_(('Id', 122) in result)
|
self.assert_(('Id', 122) in result)
|
||||||
self.assertEqual(len(result), 10)
|
self.assertEqual(len(result), 10)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.backends import dummy as backend
|
from mopidy.backends import dummy as backend
|
||||||
from mopidy.frontends.mpd import dispatcher
|
from mopidy.frontends.mpd import dispatcher
|
||||||
from mopidy.frontends.mpd.protocol import status
|
from mopidy.frontends.mpd.protocol import status
|
||||||
from mopidy.mixers import dummy as mixer
|
from mopidy.mixers import dummy as mixer
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
PAUSED = backend.PlaybackController.PAUSED
|
PAUSED = backend.PlaybackController.PAUSED
|
||||||
PLAYING = backend.PlaybackController.PLAYING
|
PLAYING = backend.PlaybackController.PLAYING
|
||||||
STOPPED = backend.PlaybackController.STOPPED
|
STOPPED = backend.PlaybackController.STOPPED
|
||||||
@ -13,6 +13,7 @@ STOPPED = backend.PlaybackController.STOPPED
|
|||||||
# FIXME migrate to using protocol.BaseTestCase instead of status.stats
|
# FIXME migrate to using protocol.BaseTestCase instead of status.stats
|
||||||
# directly?
|
# directly?
|
||||||
|
|
||||||
|
|
||||||
class StatusHandlerTest(unittest.TestCase):
|
class StatusHandlerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.backend = backend.DummyBackend.start().proxy()
|
self.backend = backend.DummyBackend.start().proxy()
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import mock
|
import mock
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.frontends.mpris import MprisFrontend, objects
|
from mopidy.frontends.mpris import MprisFrontend, objects
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class BackendEventsTest(unittest.TestCase):
|
class BackendEventsTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.mpris_frontend = MprisFrontend() # As a plain class, not an actor
|
self.mpris_frontend = MprisFrontend() # As a plain class, not an actor
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import mock
|
import mock
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.backends.dummy import DummyBackend
|
from mopidy.backends.dummy import DummyBackend
|
||||||
from mopidy.backends.base.playback import PlaybackController
|
from mopidy.backends.base.playback import PlaybackController
|
||||||
@ -7,10 +6,13 @@ from mopidy.frontends.mpris import objects
|
|||||||
from mopidy.mixers.dummy import DummyMixer
|
from mopidy.mixers.dummy import DummyMixer
|
||||||
from mopidy.models import Album, Artist, Track
|
from mopidy.models import Album, Artist, Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
PLAYING = PlaybackController.PLAYING
|
PLAYING = PlaybackController.PLAYING
|
||||||
PAUSED = PlaybackController.PAUSED
|
PAUSED = PlaybackController.PAUSED
|
||||||
STOPPED = PlaybackController.STOPPED
|
STOPPED = PlaybackController.STOPPED
|
||||||
|
|
||||||
|
|
||||||
class PlayerInterfaceTest(unittest.TestCase):
|
class PlayerInterfaceTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
objects.MprisObject._connect_to_dbus = mock.Mock()
|
objects.MprisObject._connect_to_dbus = mock.Mock()
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import mock
|
import mock
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.dummy import DummyBackend
|
from mopidy.backends.dummy import DummyBackend
|
||||||
from mopidy.frontends.mpris import objects
|
from mopidy.frontends.mpris import objects
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class RootInterfaceTest(unittest.TestCase):
|
class RootInterfaceTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
objects.exit_process = mock.Mock()
|
objects.exit_process = mock.Mock()
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
import multiprocessing
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from tests import SkipTest
|
|
||||||
|
|
||||||
# FIXME Our Windows build server does not support GStreamer yet
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'win32':
|
|
||||||
raise SkipTest
|
|
||||||
|
|
||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.gstreamer import GStreamer
|
from mopidy.gstreamer import GStreamer
|
||||||
from mopidy.utils.path import path_to_uri
|
from mopidy.utils.path import path_to_uri
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
# TODO BaseOutputTest?
|
# TODO BaseOutputTest?
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32',
|
||||||
|
'Our Windows build server does not support GStreamer yet')
|
||||||
class GStreamerTest(unittest.TestCase):
|
class GStreamerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings.BACKENDS = ('mopidy.backends.local.LocalBackend',)
|
settings.BACKENDS = ('mopidy.backends.local.LocalBackend',)
|
||||||
@ -48,11 +43,11 @@ class GStreamerTest(unittest.TestCase):
|
|||||||
self.gstreamer.start_playback()
|
self.gstreamer.start_playback()
|
||||||
self.assertTrue(self.gstreamer.stop_playback())
|
self.assertTrue(self.gstreamer.stop_playback())
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_deliver_data(self):
|
def test_deliver_data(self):
|
||||||
pass # TODO
|
pass # TODO
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_end_of_data_stream(self):
|
def test_end_of_data_stream(self):
|
||||||
pass # TODO
|
pass # TODO
|
||||||
|
|
||||||
@ -71,10 +66,10 @@ class GStreamerTest(unittest.TestCase):
|
|||||||
self.assertTrue(self.gstreamer.set_volume(100))
|
self.assertTrue(self.gstreamer.set_volume(100))
|
||||||
self.assertEqual(100, self.gstreamer.get_volume())
|
self.assertEqual(100, self.gstreamer.get_volume())
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_set_state_encapsulation(self):
|
def test_set_state_encapsulation(self):
|
||||||
pass # TODO
|
pass # TODO
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_set_position(self):
|
def test_set_position(self):
|
||||||
pass # TODO
|
pass # TODO
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
|
||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class HelpTest(unittest.TestCase):
|
class HelpTest(unittest.TestCase):
|
||||||
def test_help_has_mopidy_options(self):
|
def test_help_has_mopidy_options(self):
|
||||||
mopidy_dir = os.path.dirname(mopidy.__file__)
|
mopidy_dir = os.path.dirname(mopidy.__file__)
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.listeners import BackendListener
|
from mopidy.listeners import BackendListener
|
||||||
from mopidy.models import Track
|
from mopidy.models import Track
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class BackendListenerTest(unittest.TestCase):
|
class BackendListenerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.listener = BackendListener()
|
self.listener = BackendListener()
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.mixers.denon import DenonMixer
|
from mopidy.mixers.denon import DenonMixer
|
||||||
from tests.mixers.base_test import BaseMixerTest
|
from tests.mixers.base_test import BaseMixerTest
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class DenonMixerDeviceMock(object):
|
class DenonMixerDeviceMock(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._open = True
|
self._open = True
|
||||||
@ -24,6 +25,7 @@ class DenonMixerDeviceMock(object):
|
|||||||
def open(self):
|
def open(self):
|
||||||
self._open = True
|
self._open = True
|
||||||
|
|
||||||
|
|
||||||
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
|
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
|
||||||
ACTUAL_MAX = 99
|
ACTUAL_MAX = 99
|
||||||
INITIAL = 1
|
INITIAL = 1
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.mixers.dummy import DummyMixer
|
from mopidy.mixers.dummy import DummyMixer
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
from tests.mixers.base_test import BaseMixerTest
|
from tests.mixers.base_test import BaseMixerTest
|
||||||
|
|
||||||
|
|
||||||
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
|
class DenonMixerTest(BaseMixerTest, unittest.TestCase):
|
||||||
mixer_class = DummyMixer
|
mixer_class = DummyMixer
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import datetime as dt
|
import datetime
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.models import Artist, Album, CpTrack, Track, Playlist
|
from mopidy.models import Artist, Album, CpTrack, Track, Playlist
|
||||||
|
|
||||||
from tests import SkipTest
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class GenericCopyTets(unittest.TestCase):
|
class GenericCopyTets(unittest.TestCase):
|
||||||
def compare(self, orig, other):
|
def compare(self, orig, other):
|
||||||
@ -49,6 +49,7 @@ class GenericCopyTets(unittest.TestCase):
|
|||||||
test = lambda: Track().copy(invalid_key=True)
|
test = lambda: Track().copy(invalid_key=True)
|
||||||
self.assertRaises(TypeError, test)
|
self.assertRaises(TypeError, test)
|
||||||
|
|
||||||
|
|
||||||
class ArtistTest(unittest.TestCase):
|
class ArtistTest(unittest.TestCase):
|
||||||
def test_uri(self):
|
def test_uri(self):
|
||||||
uri = u'an_uri'
|
uri = u'an_uri'
|
||||||
@ -321,7 +322,7 @@ class TrackTest(unittest.TestCase):
|
|||||||
self.assertRaises(AttributeError, setattr, track, 'track_no', None)
|
self.assertRaises(AttributeError, setattr, track, 'track_no', None)
|
||||||
|
|
||||||
def test_date(self):
|
def test_date(self):
|
||||||
date = dt.date(1977, 1, 1)
|
date = datetime.date(1977, 1, 1)
|
||||||
track = Track(date=date)
|
track = Track(date=date)
|
||||||
self.assertEqual(track.date, date)
|
self.assertEqual(track.date, date)
|
||||||
self.assertRaises(AttributeError, setattr, track, 'date', None)
|
self.assertRaises(AttributeError, setattr, track, 'date', None)
|
||||||
@ -400,7 +401,7 @@ class TrackTest(unittest.TestCase):
|
|||||||
self.assertEqual(hash(track1), hash(track2))
|
self.assertEqual(hash(track1), hash(track2))
|
||||||
|
|
||||||
def test_eq_date(self):
|
def test_eq_date(self):
|
||||||
date = dt.date.today()
|
date = datetime.date.today()
|
||||||
track1 = Track(date=date)
|
track1 = Track(date=date)
|
||||||
track2 = Track(date=date)
|
track2 = Track(date=date)
|
||||||
self.assertEqual(track1, track2)
|
self.assertEqual(track1, track2)
|
||||||
@ -425,7 +426,7 @@ class TrackTest(unittest.TestCase):
|
|||||||
self.assertEqual(hash(track1), hash(track2))
|
self.assertEqual(hash(track1), hash(track2))
|
||||||
|
|
||||||
def test_eq(self):
|
def test_eq(self):
|
||||||
date = dt.date.today()
|
date = datetime.date.today()
|
||||||
artists = [Artist()]
|
artists = [Artist()]
|
||||||
album = Album()
|
album = Album()
|
||||||
track1 = Track(uri=u'uri', name=u'name', artists=artists, album=album,
|
track1 = Track(uri=u'uri', name=u'name', artists=artists, album=album,
|
||||||
@ -474,8 +475,8 @@ class TrackTest(unittest.TestCase):
|
|||||||
self.assertNotEqual(hash(track1), hash(track2))
|
self.assertNotEqual(hash(track1), hash(track2))
|
||||||
|
|
||||||
def test_ne_date(self):
|
def test_ne_date(self):
|
||||||
track1 = Track(date=dt.date.today())
|
track1 = Track(date=datetime.date.today())
|
||||||
track2 = Track(date=dt.date.today()-dt.timedelta(days=1))
|
track2 = Track(date=datetime.date.today()-datetime.timedelta(days=1))
|
||||||
self.assertNotEqual(track1, track2)
|
self.assertNotEqual(track1, track2)
|
||||||
self.assertNotEqual(hash(track1), hash(track2))
|
self.assertNotEqual(hash(track1), hash(track2))
|
||||||
|
|
||||||
@ -500,11 +501,11 @@ class TrackTest(unittest.TestCase):
|
|||||||
def test_ne(self):
|
def test_ne(self):
|
||||||
track1 = Track(uri=u'uri1', name=u'name1',
|
track1 = Track(uri=u'uri1', name=u'name1',
|
||||||
artists=[Artist(name=u'name1')], album=Album(name=u'name1'),
|
artists=[Artist(name=u'name1')], album=Album(name=u'name1'),
|
||||||
track_no=1, date=dt.date.today(), length=100, bitrate=100,
|
track_no=1, date=datetime.date.today(), length=100, bitrate=100,
|
||||||
musicbrainz_id='id1')
|
musicbrainz_id='id1')
|
||||||
track2 = Track(uri=u'uri2', name=u'name2',
|
track2 = Track(uri=u'uri2', name=u'name2',
|
||||||
artists=[Artist(name=u'name2')], album=Album(name=u'name2'),
|
artists=[Artist(name=u'name2')], album=Album(name=u'name2'),
|
||||||
track_no=2, date=dt.date.today()-dt.timedelta(days=1),
|
track_no=2, date=datetime.date.today()-datetime.timedelta(days=1),
|
||||||
length=200, bitrate=200, musicbrainz_id='id2')
|
length=200, bitrate=200, musicbrainz_id='id2')
|
||||||
self.assertNotEqual(track1, track2)
|
self.assertNotEqual(track1, track2)
|
||||||
self.assertNotEqual(hash(track1), hash(track2))
|
self.assertNotEqual(hash(track1), hash(track2))
|
||||||
@ -535,7 +536,7 @@ class PlaylistTest(unittest.TestCase):
|
|||||||
self.assertEqual(playlist.length, 3)
|
self.assertEqual(playlist.length, 3)
|
||||||
|
|
||||||
def test_last_modified(self):
|
def test_last_modified(self):
|
||||||
last_modified = dt.datetime.now()
|
last_modified = datetime.datetime.now()
|
||||||
playlist = Playlist(last_modified=last_modified)
|
playlist = Playlist(last_modified=last_modified)
|
||||||
self.assertEqual(playlist.last_modified, last_modified)
|
self.assertEqual(playlist.last_modified, last_modified)
|
||||||
self.assertRaises(AttributeError, setattr, playlist, 'last_modified',
|
self.assertRaises(AttributeError, setattr, playlist, 'last_modified',
|
||||||
@ -543,7 +544,7 @@ class PlaylistTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_with_new_uri(self):
|
def test_with_new_uri(self):
|
||||||
tracks = [Track()]
|
tracks = [Track()]
|
||||||
last_modified = dt.datetime.now()
|
last_modified = datetime.datetime.now()
|
||||||
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
||||||
last_modified=last_modified)
|
last_modified=last_modified)
|
||||||
new_playlist = playlist.copy(uri=u'another uri')
|
new_playlist = playlist.copy(uri=u'another uri')
|
||||||
@ -554,7 +555,7 @@ class PlaylistTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_with_new_name(self):
|
def test_with_new_name(self):
|
||||||
tracks = [Track()]
|
tracks = [Track()]
|
||||||
last_modified = dt.datetime.now()
|
last_modified = datetime.datetime.now()
|
||||||
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
||||||
last_modified=last_modified)
|
last_modified=last_modified)
|
||||||
new_playlist = playlist.copy(name=u'another name')
|
new_playlist = playlist.copy(name=u'another name')
|
||||||
@ -565,7 +566,7 @@ class PlaylistTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_with_new_tracks(self):
|
def test_with_new_tracks(self):
|
||||||
tracks = [Track()]
|
tracks = [Track()]
|
||||||
last_modified = dt.datetime.now()
|
last_modified = datetime.datetime.now()
|
||||||
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
||||||
last_modified=last_modified)
|
last_modified=last_modified)
|
||||||
new_tracks = [Track(), Track()]
|
new_tracks = [Track(), Track()]
|
||||||
@ -577,8 +578,8 @@ class PlaylistTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_with_new_last_modified(self):
|
def test_with_new_last_modified(self):
|
||||||
tracks = [Track()]
|
tracks = [Track()]
|
||||||
last_modified = dt.datetime.now()
|
last_modified = datetime.datetime.now()
|
||||||
new_last_modified = last_modified + dt.timedelta(1)
|
new_last_modified = last_modified + datetime.timedelta(1)
|
||||||
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
|
||||||
last_modified=last_modified)
|
last_modified=last_modified)
|
||||||
new_playlist = playlist.copy(last_modified=new_last_modified)
|
new_playlist = playlist.copy(last_modified=new_last_modified)
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import unittest
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from mopidy.scanner import Scanner, translator
|
from mopidy.scanner import Scanner, translator
|
||||||
from mopidy.models import Track, Artist, Album
|
from mopidy.models import Track, Artist, Album
|
||||||
|
|
||||||
from tests import path_to_data_dir, SkipTest
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
|
|
||||||
class FakeGstDate(object):
|
class FakeGstDate(object):
|
||||||
def __init__(self, year, month, day):
|
def __init__(self, year, month, day):
|
||||||
@ -12,6 +12,7 @@ class FakeGstDate(object):
|
|||||||
self.month = month
|
self.month = month
|
||||||
self.day = day
|
self.day = day
|
||||||
|
|
||||||
|
|
||||||
class TranslatorTest(unittest.TestCase):
|
class TranslatorTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.data = {
|
self.data = {
|
||||||
@ -126,6 +127,7 @@ class TranslatorTest(unittest.TestCase):
|
|||||||
del self.track['date']
|
del self.track['date']
|
||||||
self.check()
|
self.check()
|
||||||
|
|
||||||
|
|
||||||
class ScannerTest(unittest.TestCase):
|
class ScannerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.errors = {}
|
self.errors = {}
|
||||||
@ -185,6 +187,6 @@ class ScannerTest(unittest.TestCase):
|
|||||||
self.scan('scanner/image')
|
self.scan('scanner/image')
|
||||||
self.assert_(self.errors)
|
self.assert_(self.errors)
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_song_without_time_is_handeled(self):
|
def test_song_without_time_is_handeled(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.utils import get_class
|
from mopidy.utils import get_class
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class GetClassTest(unittest.TestCase):
|
class GetClassTest(unittest.TestCase):
|
||||||
def test_loading_module_that_does_not_exist(self):
|
def test_loading_module_that_does_not_exist(self):
|
||||||
self.assertRaises(ImportError, get_class, 'foo.bar.Baz')
|
self.assertRaises(ImportError, get_class, 'foo.bar.Baz')
|
||||||
|
|||||||
@ -3,12 +3,12 @@ import gobject
|
|||||||
import logging
|
import logging
|
||||||
import pykka
|
import pykka
|
||||||
import socket
|
import socket
|
||||||
import unittest
|
from mock import patch, sentinel, Mock
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.utils import network
|
||||||
|
|
||||||
from mock import patch, sentinel, Mock
|
from tests import unittest, any_int, any_unicode
|
||||||
from tests import any_int, any_unicode, SkipTest
|
|
||||||
|
|
||||||
class ConnectionTest(unittest.TestCase):
|
class ConnectionTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
#encoding: utf-8
|
#encoding: utf-8
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import unittest
|
from mock import sentinel, Mock
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.utils import network
|
||||||
|
|
||||||
from mock import sentinel, Mock
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class LineProtocolTest(unittest.TestCase):
|
class LineProtocolTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import errno
|
import errno
|
||||||
import gobject
|
import gobject
|
||||||
import socket
|
import socket
|
||||||
import unittest
|
from mock import patch, sentinel, Mock
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.utils import network
|
||||||
|
|
||||||
from mock import patch, sentinel, Mock
|
from tests import unittest, any_int
|
||||||
from tests import any_int
|
|
||||||
|
|
||||||
class ServerTest(unittest.TestCase):
|
class ServerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import socket
|
import socket
|
||||||
import unittest
|
from mock import patch, Mock
|
||||||
|
|
||||||
from mopidy.utils import network
|
from mopidy.utils import network
|
||||||
|
|
||||||
from mock import patch, Mock
|
from tests import unittest
|
||||||
from tests import SkipTest
|
|
||||||
|
|
||||||
class FormatHostnameTest(unittest.TestCase):
|
class FormatHostnameTest(unittest.TestCase):
|
||||||
@patch('mopidy.utils.network.has_ipv6', True)
|
@patch('mopidy.utils.network.has_ipv6', True)
|
||||||
@ -52,6 +52,6 @@ class CreateSocketTest(unittest.TestCase):
|
|||||||
self.assertEqual(socket_mock.call_args[0],
|
self.assertEqual(socket_mock.call_args[0],
|
||||||
(socket.AF_INET6, socket.SOCK_STREAM))
|
(socket.AF_INET6, socket.SOCK_STREAM))
|
||||||
|
|
||||||
@SkipTest
|
@unittest.SkipTest
|
||||||
def test_ipv6_only_is_set(self):
|
def test_ipv6_only_is_set(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -4,12 +4,12 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy.utils.path import (get_or_create_folder, mtime,
|
from mopidy.utils.path import (get_or_create_folder, mtime,
|
||||||
path_to_uri, uri_to_path, split_path, find_files)
|
path_to_uri, uri_to_path, split_path, find_files)
|
||||||
|
|
||||||
from tests import path_to_data_dir
|
from tests import unittest, path_to_data_dir
|
||||||
|
|
||||||
|
|
||||||
class GetOrCreateFolderTest(unittest.TestCase):
|
class GetOrCreateFolderTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
|
||||||
|
|
||||||
from mopidy import settings as default_settings_module, SettingsError
|
from mopidy import settings as default_settings_module, SettingsError
|
||||||
from mopidy.utils.settings import (format_settings_list, mask_value_if_secret,
|
from mopidy.utils.settings import (format_settings_list, mask_value_if_secret,
|
||||||
SettingsProxy, validate_settings)
|
SettingsProxy, validate_settings)
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class ValidateSettingsTest(unittest.TestCase):
|
class ValidateSettingsTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.defaults = {
|
self.defaults = {
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
from distutils.version import StrictVersion as SV
|
from distutils.version import StrictVersion as SV
|
||||||
import unittest
|
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
from mopidy import get_version, get_plain_version, get_platform, get_python
|
from mopidy import get_plain_version, get_platform, get_python
|
||||||
|
|
||||||
|
from tests import unittest
|
||||||
|
|
||||||
|
|
||||||
class VersionTest(unittest.TestCase):
|
class VersionTest(unittest.TestCase):
|
||||||
def test_current_version_is_parsable_as_a_strict_version_number(self):
|
def test_current_version_is_parsable_as_a_strict_version_number(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user