Basic test and extension setup
parent
a21c8f255b
commit
977647684b
|
@ -1,7 +1,37 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Top-level package for mopidy-funkwhale."""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import mopidy.config
|
||||
import mopidy.ext
|
||||
import os
|
||||
|
||||
|
||||
__author__ = """Eliot Berriot"""
|
||||
__email__ = 'contact+funkwhale@eliotberriot.com'
|
||||
__version__ = '0.1.0'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Extension(mopidy.ext.Extension):
|
||||
|
||||
dist_name = 'Mopidy-Funkwhale'
|
||||
ext_name = 'funkwhale'
|
||||
version = __version__
|
||||
|
||||
def get_default_config(self):
|
||||
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
||||
return mopidy.config.read(conf_file)
|
||||
|
||||
def get_config_schema(self):
|
||||
schema = super(Extension, self).get_config_schema()
|
||||
schema['url'] = mopidy.config.String()
|
||||
schema['username'] = mopidy.config.Secret(optional=True)
|
||||
schema['password'] = mopidy.config.Secret(optional=True)
|
||||
return schema
|
||||
|
||||
def setup(self, registry):
|
||||
from .backend import FoobarBackend
|
||||
registry.add('backend', FoobarBackend)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[funkwhale]
|
||||
enabled = true
|
||||
url = https://demo.funkwhale.audio
|
||||
username = demo
|
||||
password = demo
|
|
@ -1,3 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Main module."""
|
12
setup.cfg
12
setup.cfg
|
@ -19,14 +19,24 @@ zip_safe = True
|
|||
include_package_data = True
|
||||
packages = find:
|
||||
install_requires =
|
||||
mopidy
|
||||
requests
|
||||
|
||||
[options.extras_require]
|
||||
|
||||
[options.entry_points]
|
||||
mopidy.ext =
|
||||
funkwhale = mopidy_funkwhale:Extension
|
||||
|
||||
[options.extras_require]
|
||||
test =
|
||||
pytest
|
||||
pytest-cov
|
||||
|
||||
dev =
|
||||
pygobject
|
||||
ipython
|
||||
ipdb
|
||||
|
||||
[options.packages.find]
|
||||
exclude =
|
||||
tests
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
"""Tests for `mopidy_funkwhale` package."""
|
||||
|
||||
import pytest
|
||||
import mopidy_funkwhale
|
||||
|
||||
|
||||
from mopidy_funkwhale import mopidy_funkwhale
|
||||
def test_get_default_config():
|
||||
ext = mopidy_funkwhale.Extension()
|
||||
|
||||
config = ext.get_default_config()
|
||||
|
||||
assert '[funkwhale]' in config
|
||||
assert 'enabled = true' in config
|
||||
assert 'url = https://demo.funkwhale.audio' in config
|
||||
assert 'username = demo' in config
|
||||
assert 'password = demo' in config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def response():
|
||||
"""Sample pytest fixture.
|
||||
def test_get_config_schema():
|
||||
ext = mopidy_funkwhale.Extension()
|
||||
|
||||
See more at: http://doc.pytest.org/en/latest/fixture.html
|
||||
"""
|
||||
# import requests
|
||||
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
|
||||
|
||||
|
||||
def test_content(response):
|
||||
"""Sample pytest test function with the pytest fixture as an argument."""
|
||||
# from bs4 import BeautifulSoup
|
||||
# assert 'GitHub' in BeautifulSoup(response.content).title.string
|
||||
schema = ext.get_config_schema()
|
||||
assert 'url' in schema
|
||||
assert 'username' in schema
|
||||
assert 'password' in schema
|
||||
|
|
Loading…
Reference in New Issue