Cleaning up pre-tests

This commit is contained in:
James Barnsley
2020-02-03 16:13:49 +13:00
parent be11731db3
commit 9fa47ab734
5 changed files with 32 additions and 40 deletions

View File

@ -1,4 +1,5 @@
include mopidy_iris/ext.conf
include mopidy_iris/system.sh
include IRIS_VERSION
recursive-include mopidy_iris/static *
recursive-include mopidy_iris/static *
recursive-include mopidy_iris *.py

View File

@ -1,29 +0,0 @@
# defaults file for snapserver
# start snapserver automatically?
START_SNAPSERVER=true
# Allowed options:
# -h, --help Produce help message
# -v, --version Show version number
# -p, --port arg (=1704) Server port
# --controlPort arg (=1705) Remote control port
# -s, --stream arg (=pipe:///tmp/snapfifo?name=default)
# URI of the PCM input stream.
# Format: TYPE://host/path?name=NAME
# [&codec=CODEC]
# [&sampleformat=SAMPLEFORMAT]
# --sampleformat arg (=48000:16:2) Default sample format
# -c, --codec arg (=flac) Default transport codec
# (flac|ogg|pcm)[:options]
# Type codec:? to get codec specific options
# --streamBuffer arg (=20) Default stream read buffer [ms]
# -b, --buffer arg (=1000) Buffer [ms]
# --sendToMuted Send audio to muted clients
# -d, --daemon [=arg(=0)] Daemonize
# optional process priority [-20..19]
# --user arg the user[:group] to run snapserver as when daemonized
USER_OPTS="--user snapserver:snapserver"
SNAPSERVER_OPTS="-s pipe:///tmp/snapfifo?name=Mopidy&sampleformat=48000:16:2"

View File

@ -14,7 +14,7 @@ def test_get_default_config():
def test_get_config_schema():
ext = Extension()
schema = ext.get_config_schema()
# schema = ext.get_config_schema()
# TODO Test the content of your config schema
# assert "username" in schema

View File

@ -29,7 +29,7 @@ def process_mock(popen_mock):
yield mock_process
def test_can_run_args(popen_mock, process_mock):
IrisSystemThread('foo', None).can_run()
IrisSystemThread('foo', None, None).can_run()
popen_mock.assert_called_once_with(
mock.ANY,
shell=True,
@ -38,21 +38,21 @@ def test_can_run_args(popen_mock, process_mock):
)
def test_can_run_uses_sudo_non_interactive(popen_mock, process_mock):
IrisSystemThread('foo', None).can_run()
IrisSystemThread('foo', None, None).can_run()
popen_mock.assert_called_once()
assert popen_mock.call_args[0][0].startswith(b"sudo -n ")
def test_can_run_calls_script_check(popen_mock, process_mock):
IrisSystemThread('foo', None).can_run()
IrisSystemThread('foo', None, None).can_run()
assert popen_mock.call_args[0][0].endswith(b"system.sh check")
def test_can_run_sudo_refused_raises(popen_mock, process_mock, caplog):
process_mock.wait.return_value = 1
iris_system = IrisSystemThread('foo', None)
iris_system = IrisSystemThread('foo', None, None)
with pytest.raises(IrisSystemPermissionError) as excinfo:
iris_system.can_run()
@ -66,7 +66,7 @@ def test_can_run_sudo_refused_raises(popen_mock, process_mock, caplog):
def test_run_args(popen_mock, process_mock):
iris_system = IrisSystemThread('foo', mock.Mock())
iris_system = IrisSystemThread('foo', mock.Mock(), None)
iris_system.can_run = mock.Mock(return_value = True)
iris_system.run()
@ -78,9 +78,9 @@ def test_run_args(popen_mock, process_mock):
def test_run_uses_sudo(popen_mock, process_mock):
iris_system = IrisSystemThread('foo', mock.Mock())
iris_system = IrisSystemThread('foo', mock.Mock(), None)
iris_system.can_run = mock.Mock(return_value = True)
iris_system.run()
popen_mock.assert_called_once()
assert popen_mock.call_args[0][0][0] == b"sudo"

22
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py37, py38, black, flake8
envlist = py37, py38, black, check-manifest, flake8
[testenv]
sitepackages = true
@ -14,6 +14,26 @@ commands =
deps = .[lint]
commands = python -m black --check .
[testenv:check-manifest]
deps = .[lint]
commands = python -m check_manifest
ignore =
build_tools
build_tools/*
docker
docker/*
Screenshots
Screenshots/*
src
src/*
.circleci
.circleci/*
.dockerignore
.htaccess
.vscode
.vscode/*
.dockerignore
[testenv:flake8]
deps = .[lint]
commands = python -m flake8 --show-source --statistics