Skip to content

Commit

Permalink
Merge branch 'release-0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisNT committed Mar 21, 2020
2 parents 3535309 + e7bad30 commit 4508e6a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 64 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
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"

script:
- "tox -e $TOX_ENV"

after_success:
- "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi"
- "if [ $TOX_ENV == 'py37' ]; then pip install coveralls requests; coveralls; fi"
24 changes: 24 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=================

Expand All @@ -64,6 +83,11 @@ Project resources
Changelog
=========

v0.1.2
----------------------------------------

- Upgraded to Mopidy 3.0+ and Python 3.7+.

v0.1.1
----------------------------------------

Expand Down
12 changes: 5 additions & 7 deletions mopidy_playbackdefaults/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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'])
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import re

from setuptools import find_packages, setup
Expand All @@ -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',
Expand All @@ -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',
],
)
2 changes: 0 additions & 2 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import unittest

import mock
Expand Down
94 changes: 48 additions & 46 deletions tests/test_frontend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import unittest

import mock
Expand All @@ -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)
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, flake8
envlist = py37, flake8

[testenv]
sitepackages = true
Expand All @@ -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]
Expand Down

0 comments on commit 4508e6a

Please sign in to comment.