diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..bfd4689 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,51 @@ +version: 2.1 + +orbs: + codecov: codecov/codecov@1.0.5 + +workflows: + version: 2 + test: + jobs: + - py38 + - py37 + - black + - check-manifest + - flake8 + +jobs: + py38: &test-template + docker: + - image: mopidy/ci-python:3.8 + steps: + - checkout + - restore_cache: + name: Restoring tox cache + key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} + - run: + name: Run tests + command: | + tox -e $CIRCLE_JOB -- \ + --junit-xml=test-results/pytest/results.xml \ + --cov-report=xml + - save_cache: + name: Saving tox cache + key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} + paths: + - ./.tox + - ~/.cache/pip + - codecov/upload: + file: coverage.xml + - store_test_results: + path: test-results + + py37: + <<: *test-template + docker: + - image: mopidy/ci-python:3.7 + + black: *test-template + + check-manifest: *test-template + + flake8: *test-template diff --git a/.gitignore b/.gitignore index 4cd6c95..03640c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ -build/ -dist/ -*.conf -venv/ -*.egg-info *.pyc +/.coverage +/.mypy_cache/ +/.pytest_cache/ +/.tox/ +/*.egg-info +/build/ +/dist/ +/MANIFEST diff --git a/MANIFEST.in b/MANIFEST.in index 6def079..7734bb0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,15 @@ +include *.py +include *.rst +include .mailmap include LICENSE include MANIFEST.in -include README.md -include mopidy_subidy/ext.conf +include pyproject.toml +include tox.ini + +recursive-include .circleci * +recursive-include .github * + +include mopidy_*/ext.conf + +recursive-include tests *.py +recursive-include tests/data * diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bff16e0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["setuptools >= 30.3.0", "wheel"] + + +[tool.black] +target-version = ["py37", "py38"] +line-length = 80 + + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 +known_tests = "tests" +sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a0e77d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,87 @@ +[metadata] +name = Mopidy-Subidy +version = 0.2.1 +url = https://github.com/Prior99/mopidy-subidy +author = prior99 +author_email = fgnodtke@cronosx.de +license = BSD-3-Clause +license_file = LICENSE +description = Subsonic extension for Mopidy +long_description = file: README.md +long_description_content_type = text/markdown +classifiers = + Environment :: No Input/Output (Daemon) + Intended Audience :: End Users/Desktop + License :: OSI Approved :: BSD License + Operating System :: OS Independent + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Topic :: Multimedia :: Sound/Audio :: Players + + +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >= 3.7 +install_requires = + Mopidy >= 3.0.0 + Pykka >= 2.0.1 + setuptools + py-sonic >= 0.7.7 + + +[options.extras_require] +lint = + black + check-manifest + flake8 + flake8-bugbear + flake8-import-order + isort[pyproject] +release = + twine + wheel +test = + pytest + pytest-cov +dev = + %(lint)s + %(release)s + %(test)s + + +[options.packages.find] +exclude = + tests + tests.* + + +[options.entry_points] +mopidy.ext = + subidy = mopidy_subidy:SubidyExtension + + +[flake8] +application-import-names = mopidy_subidy, tests +max-line-length = 80 +exclude = .git, .tox, build +select = + # Regular flake8 rules + C, E, F, W + # flake8-bugbear rules + B + # B950: line too long (soft speed limit) + B950 + # pep8-naming rules + N +ignore = + # E203: whitespace before ':' (not PEP8 compliant) + E203 + # E501: line too long (replaced by B950) + E501 + # W503: line break before binary operator (not PEP8 compliant) + W503 + # B305: .next() is not a thing on Python 3 (used by playback controller) + B305 diff --git a/setup.py b/setup.py index 41863e2..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,43 +1,3 @@ -from __future__ import unicode_literals +from setuptools import setup -import re -from setuptools import setup, find_packages - - -def get_version(filename): - content = open(filename).read() - metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", content)) - return metadata['version'] - -setup( - name='Mopidy-Subidy', - version=get_version('mopidy_subidy/__init__.py'), - url='http://github.com/prior99/mopidy-subidy/', - license='BSD-3-Clause', - author='prior99', - author_email='fgnodtke@cronosx.de', - description='Improved Subsonic extension for Mopidy', - long_description=open('README.md').read(), - packages=find_packages(exclude=['tests', 'tests.*']), - zip_safe=False, - include_package_data=True, - install_requires=[ - 'setuptools', - 'Mopidy >= 2.0', - 'py-sonic >= 0.7.7', - 'Pykka >= 1.1' - ], - entry_points={ - 'mopidy.ext': [ - 'subidy = mopidy_subidy:SubidyExtension', - ], - }, - classifiers=[ - 'Environment :: No Input/Output (Daemon)', - 'Intended Audience :: End Users/Desktop', - 'License :: OSI Approved :: BSD 3-Clause', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Topic :: Multimedia :: Sound/Audio :: Players' - ] -) +setup() 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..b2fa67f --- /dev/null +++ b/tests/test_extension.py @@ -0,0 +1,23 @@ +from mopidy_subidy import SubidyExtension + + +def test_get_default_config(): + ext = SubidyExtension() + + config = ext.get_default_config() + + assert "[subidy]" in config + assert "enabled = true" in config + + +def test_get_config_schema(): + ext = SubidyExtension() + + schema = ext.get_config_schema() + + # TODO Test the content of your config schema + # assert "username" in schema + # assert "password" in schema + + +# TODO Write more tests diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..50c10fe --- /dev/null +++ b/tox.ini @@ -0,0 +1,23 @@ +[tox] +envlist = py37, py38, black, check-manifest, flake8 + +[testenv] +sitepackages = true +deps = .[test] +commands = + python -m pytest \ + --basetemp={envtmpdir} \ + --cov=mopidy_subidy --cov-report=term-missing \ + {posargs} + +[testenv:black] +deps = .[lint] +commands = python -m black --check . + +[testenv:check-manifest] +deps = .[lint] +commands = python -m check_manifest + +[testenv:flake8] +deps = .[lint] +commands = python -m flake8 --show-source --statistics