diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..e77617c --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[report] +omit = + */pyshared/* + */python?.?/* + */site-packages/nose/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..65b5634 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: python + +python: + - "2.7_with_system_site_packages" + +env: + - TOX_ENV=py27 + - TOX_ENV=flake8 + +install: + - "wget -O - http://apt.mopidy.com/mopidy.gpg | sudo apt-key add -" + - "sudo wget -O /etc/apt/sources.list.d/mopidy.list http://apt.mopidy.com/mopidy.list" + - "sudo apt-get update || true" + - "sudo apt-get install mopidy" + - "pip install tox" + +script: + - "tox -e $TOX_ENV" + +after_success: + - "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi" diff --git a/MANIFEST.in b/MANIFEST.in index 6c97bbd..49993d9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,9 @@ +include .coveragerc +include .travis.yml include AUTHORS include LICENSE include MANIFEST.in include README.rst include mopidy_musicbox_webclient/ext.conf -recursive-include mopidy_musicbox_webclient/static * +recursive-include tests mopidy_musicbox_webclient/static * diff --git a/setup.cfg b/setup.cfg index 5e40900..082e471 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,6 @@ +[flake8] +application-import-names = mopidy_musicbox_webclient,tests +exclude = .git,.tox + [wheel] universal = 1 diff --git a/setup.py b/setup.py index 9d7a0c5..c594f79 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( author_email='woutervanwijk@gmail.com', description='Mopidy MusicBox web extension', long_description=open('README.rst').read(), - packages=find_packages(), + packages=find_packages(exclude=['tests', 'tests.*']), zip_safe=False, include_package_data=True, install_requires=[ diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_extension.py b/tests/test_extension.py new file mode 100644 index 0000000..22ebe58 --- /dev/null +++ b/tests/test_extension.py @@ -0,0 +1,23 @@ +from __future__ import unicode_literals + +from mopidy_musicbox_webclient import MusicBoxExtension + + +def test_get_default_config(): + ext = MusicBoxExtension() + + config = ext.get_default_config() + + assert '[musicbox_webclient]' in config + assert 'enabled = true' in config + + +def test_get_config_schema(): + ext = MusicBoxExtension() + + schema = ext.get_config_schema() + + # TODO Test the content of your config schema + + +# TODO Write more tests diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c9d3e79 --- /dev/null +++ b/tox.ini @@ -0,0 +1,24 @@ +[tox] +envlist = py27, flake8 + +[testenv] +sitepackages = true +deps = + mock + mopidy==dev + pytest + pytest-cov + pytest-xdist +install_command = pip install --allow-unverified=mopidy --pre {opts} {packages} +commands = + py.test \ + --basetemp={envtmpdir} \ + --junit-xmlfile=xunit-{envname}.xml \ + --cov=mopidy_musicbox_webclient --cov-report=term-missing \ + {posargs} + +[testenv:flake8] +deps = + flake8 + flake8-import-order +commands = flake8