diff --git a/.travis.yml b/.travis.yml index 1890198..c629f11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,20 @@ language: python +os: linux +dist: bionic python: - - "2.7_with_system_site_packages" + - "3.7" env: - - TOX_ENV=py27 + - TOX_ENV=py37 - TOX_ENV=flake8 +before_install: + # Mock Python gi package + - export PYUSRSITEDIR=$(python -m site --user-site) + - mkdir -p $PYUSRSITEDIR + - "echo \"import sys; import mock; sys.modules['gi'] = mock.Mock(); sys.modules['gi.repository'] = mock.Mock(); sys.modules['gi.repository'].Gst.version.side_effect = lambda: (1, 14, 0)\" > ${PYUSRSITEDIR}/usercustomize.py" + install: - "pip install tox" @@ -14,4 +22,4 @@ script: - "tox -e $TOX_ENV" after_success: - - "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi" \ No newline at end of file + - "if [ $TOX_ENV == 'py37' ]; then pip install coveralls requests; coveralls; fi" \ No newline at end of file diff --git a/README.rst b/README.rst index 858bae1..5ee8a48 100644 --- a/README.rst +++ b/README.rst @@ -53,6 +53,25 @@ Usage During Mopidy startup playback settings will be automatically adjusted according to configuration. +License +============= +:: + + Copyright 2016-2020 Davis Mosenkovs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Project resources ================= @@ -64,6 +83,11 @@ Project resources Changelog ========= +v0.1.2 +---------------------------------------- + +- Upgraded to Mopidy 3.0+ and Python 3.7+. + v0.1.1 ---------------------------------------- diff --git a/mopidy_playbackdefaults/__init__.py b/mopidy_playbackdefaults/__init__.py index c8ef014..af54e1b 100644 --- a/mopidy_playbackdefaults/__init__.py +++ b/mopidy_playbackdefaults/__init__.py @@ -1,12 +1,10 @@ -from __future__ import unicode_literals - import os from mopidy import config, ext import pykka -__version__ = '0.1.1' +__version__ = '0.1.2' class PlaybackDefaultsExtension(ext.Extension): @@ -36,10 +34,10 @@ def __init__(self, config, core): super(PlaybackDefaultsFrontend, self).__init__() if type(config[PlaybackDefaultsExtension.ext_name]['default_random']) is bool: - core.tracklist.random = config[PlaybackDefaultsExtension.ext_name]['default_random'] + core.tracklist.set_random(config[PlaybackDefaultsExtension.ext_name]['default_random']) if type(config[PlaybackDefaultsExtension.ext_name]['default_repeat']) is bool: - core.tracklist.repeat = config[PlaybackDefaultsExtension.ext_name]['default_repeat'] + core.tracklist.set_repeat(config[PlaybackDefaultsExtension.ext_name]['default_repeat']) if type(config[PlaybackDefaultsExtension.ext_name]['default_consume']) is bool: - core.tracklist.consume = config[PlaybackDefaultsExtension.ext_name]['default_consume'] + core.tracklist.set_consume(config[PlaybackDefaultsExtension.ext_name]['default_consume']) if type(config[PlaybackDefaultsExtension.ext_name]['default_single']) is bool: - core.tracklist.single = config[PlaybackDefaultsExtension.ext_name]['default_single'] + core.tracklist.set_single(config[PlaybackDefaultsExtension.ext_name]['default_single']) diff --git a/setup.py b/setup.py index 9e69977..1784ab4 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import re from setuptools import find_packages, setup @@ -23,9 +21,10 @@ def get_version(filename): packages=find_packages(exclude=['tests', 'tests.*']), zip_safe=False, include_package_data=True, + python_requires='>= 3.7', install_requires=[ 'setuptools', - 'Mopidy >= 0.19', + 'Mopidy >= 3.0', 'Pykka >= 1.1', ], test_suite='nose.collector', @@ -43,7 +42,7 @@ def get_version(filename): 'Intended Audience :: End Users/Desktop', 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', 'Topic :: Multimedia :: Sound/Audio :: Players', ], ) diff --git a/tests/test_extension.py b/tests/test_extension.py index d428c03..dc03f7d 100644 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import unittest import mock diff --git a/tests/test_frontend.py b/tests/test_frontend.py index 7a15187..10f1c88 100644 --- a/tests/test_frontend.py +++ b/tests/test_frontend.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import unittest import mock @@ -12,94 +10,98 @@ class PlaybackDefaultsFrontendTest(unittest.TestCase): def test_no_settings(self): config = {'playbackdefaults': {'default_random': '', 'default_repeat': '', 'default_consume': '', 'default_single': ''}} core = mock.Mock() - core.tracklist.random = 'untouched' - core.tracklist.repeat = 'untouched' - core.tracklist.consume = 'untouched' - core.tracklist.single = 'untouched' + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) PlaybackDefaultsFrontend(config, core) - self.assertEqual(core.tracklist.random, 'untouched') - self.assertEqual(core.tracklist.repeat, 'untouched') - self.assertEqual(core.tracklist.consume, 'untouched') - self.assertEqual(core.tracklist.single, 'untouched') + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) def test_random(self): config = {'playbackdefaults': {'default_random': '', 'default_repeat': '', 'default_consume': '', 'default_single': ''}} core = mock.Mock() - core.tracklist.random = 'untouched' - core.tracklist.repeat = 'untouched' - core.tracklist.consume = 'untouched' - core.tracklist.single = 'untouched' + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) config['playbackdefaults']['default_random'] = True PlaybackDefaultsFrontend(config, core) - self.assertTrue(core.tracklist.random) + core.tracklist.set_random.assert_called_once_with(True) config['playbackdefaults']['default_random'] = False PlaybackDefaultsFrontend(config, core) - self.assertFalse(core.tracklist.random) + self.assertEqual(core.tracklist.set_random.call_count, 2) + core.tracklist.set_random.assert_called_with(False) - self.assertEqual(core.tracklist.repeat, 'untouched') - self.assertEqual(core.tracklist.consume, 'untouched') - self.assertEqual(core.tracklist.single, 'untouched') + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) def test_repeat(self): config = {'playbackdefaults': {'default_random': '', 'default_repeat': '', 'default_consume': '', 'default_single': ''}} core = mock.Mock() - core.tracklist.random = 'untouched' - core.tracklist.repeat = 'untouched' - core.tracklist.consume = 'untouched' - core.tracklist.single = 'untouched' + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) config['playbackdefaults']['default_repeat'] = True PlaybackDefaultsFrontend(config, core) - self.assertTrue(core.tracklist.repeat) + core.tracklist.set_repeat.assert_called_once_with(True) config['playbackdefaults']['default_repeat'] = False PlaybackDefaultsFrontend(config, core) - self.assertFalse(core.tracklist.repeat) + self.assertEqual(core.tracklist.set_repeat.call_count, 2) + core.tracklist.set_repeat.assert_called_with(False) - self.assertEqual(core.tracklist.random, 'untouched') - self.assertEqual(core.tracklist.consume, 'untouched') - self.assertEqual(core.tracklist.single, 'untouched') + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) def test_consume(self): config = {'playbackdefaults': {'default_random': '', 'default_repeat': '', 'default_consume': '', 'default_single': ''}} core = mock.Mock() - core.tracklist.random = 'untouched' - core.tracklist.repeat = 'untouched' - core.tracklist.consume = 'untouched' - core.tracklist.single = 'untouched' + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) config['playbackdefaults']['default_consume'] = True PlaybackDefaultsFrontend(config, core) - self.assertTrue(core.tracklist.consume) + core.tracklist.set_consume.assert_called_once_with(True) config['playbackdefaults']['default_consume'] = False PlaybackDefaultsFrontend(config, core) - self.assertFalse(core.tracklist.consume) + self.assertEqual(core.tracklist.set_consume.call_count, 2) + core.tracklist.set_consume.assert_called_with(False) - self.assertEqual(core.tracklist.random, 'untouched') - self.assertEqual(core.tracklist.repeat, 'untouched') - self.assertEqual(core.tracklist.single, 'untouched') + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) def test_single(self): config = {'playbackdefaults': {'default_random': '', 'default_repeat': '', 'default_consume': '', 'default_single': ''}} core = mock.Mock() - core.tracklist.random = 'untouched' - core.tracklist.repeat = 'untouched' - core.tracklist.consume = 'untouched' - core.tracklist.single = 'untouched' + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) + self.assertEqual(core.tracklist.set_single.call_count, 0) config['playbackdefaults']['default_single'] = True PlaybackDefaultsFrontend(config, core) - self.assertTrue(core.tracklist.single) + core.tracklist.set_single.assert_called_once_with(True) config['playbackdefaults']['default_single'] = False PlaybackDefaultsFrontend(config, core) - self.assertFalse(core.tracklist.single) + self.assertEqual(core.tracklist.set_single.call_count, 2) + core.tracklist.set_single.assert_called_with(False) - self.assertEqual(core.tracklist.random, 'untouched') - self.assertEqual(core.tracklist.repeat, 'untouched') - self.assertEqual(core.tracklist.consume, 'untouched') + self.assertEqual(core.tracklist.set_random.call_count, 0) + self.assertEqual(core.tracklist.set_repeat.call_count, 0) + self.assertEqual(core.tracklist.set_consume.call_count, 0) diff --git a/tox.ini b/tox.ini index a82a886..ec3bc5a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, flake8 +envlist = py37, flake8 [testenv] sitepackages = true @@ -9,7 +9,6 @@ deps = nose freezegun mopidy -install_command = pip install --allow-unverified=mopidy --pre {opts} {packages} commands = nosetests -v --with-xunit --xunit-file=xunit-{envname}.xml --with-coverage --cover-package=mopidy_playbackdefaults [testenv:flake8]