From 9fa47ab734cea2e04522f6b5f89e6c5c8b8e2746 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Mon, 3 Feb 2020 16:13:49 +1300 Subject: [PATCH] Cleaning up pre-tests --- MANIFEST.in | 3 ++- docker/snapserver copy | 29 ----------------------------- tests/test_extension.py | 2 +- tests/test_system.py | 16 ++++++++-------- tox.ini | 22 +++++++++++++++++++++- 5 files changed, 32 insertions(+), 40 deletions(-) delete mode 100755 docker/snapserver copy diff --git a/MANIFEST.in b/MANIFEST.in index 47a07b0b..d1058ff4 100755 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include mopidy_iris/ext.conf include mopidy_iris/system.sh include IRIS_VERSION -recursive-include mopidy_iris/static * \ No newline at end of file +recursive-include mopidy_iris/static * +recursive-include mopidy_iris *.py \ No newline at end of file diff --git a/docker/snapserver copy b/docker/snapserver copy deleted file mode 100755 index eab7604c..00000000 --- a/docker/snapserver copy +++ /dev/null @@ -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" \ No newline at end of file diff --git a/tests/test_extension.py b/tests/test_extension.py index aacbf57f..6bb152c0 100755 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -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 diff --git a/tests/test_system.py b/tests/test_system.py index 95ffbc53..7bd7ac81 100755 --- a/tests/test_system.py +++ b/tests/test_system.py @@ -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" diff --git a/tox.ini b/tox.ini index 8bcd04c2..eda38c80 100755 --- a/tox.ini +++ b/tox.ini @@ -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