mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
tests: Fix flake8 warning about unused imports
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
fb8ed2a700
commit
30d6297c89
57
plinth/tests/conftest.py
Normal file
57
plinth/tests/conftest.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#
|
||||||
|
# This file is part of FreedomBox.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
"""
|
||||||
|
pytest configuration for all tests in the plinth/tests/ directory.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
NEXTCLOUD_SHORTCUT = {
|
||||||
|
'name':
|
||||||
|
'NextCloud',
|
||||||
|
'short_description':
|
||||||
|
'File Hosting Service',
|
||||||
|
'description': [
|
||||||
|
'Nextcloud is a suite of client-server software for creating '
|
||||||
|
'and using file hosting services.'
|
||||||
|
],
|
||||||
|
'icon_url':
|
||||||
|
'/plinth/custom/static/themes/default/icons/nextcloud.png',
|
||||||
|
'clients': [{
|
||||||
|
'name': 'nextcloud',
|
||||||
|
'platforms': [{
|
||||||
|
'type': 'web',
|
||||||
|
'url': '/nextcloud'
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name='custom_shortcuts_file')
|
||||||
|
def fixture_custom_shortcuts_file(load_cfg, tmp_path):
|
||||||
|
"""Fixture to set path for a custom shortcuts file."""
|
||||||
|
load_cfg.config_file = str(tmp_path / 'plinth.conf')
|
||||||
|
return tmp_path / 'custom-shortcuts.json'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name='nextcloud_shortcut')
|
||||||
|
def fixture_nextcloud_shortcut(custom_shortcuts_file):
|
||||||
|
"""Create a custom_shortcuts file with NextCloud shortcut."""
|
||||||
|
shortcuts = {'shortcuts': [NEXTCLOUD_SHORTCUT]}
|
||||||
|
custom_shortcuts_file.write_text(json.dumps(shortcuts))
|
||||||
@ -24,32 +24,7 @@ import pytest
|
|||||||
|
|
||||||
from plinth.modules.api.views import get_shortcuts_as_json
|
from plinth.modules.api.views import get_shortcuts_as_json
|
||||||
|
|
||||||
NEXTCLOUD_SHORTCUT = {
|
from .conftest import NEXTCLOUD_SHORTCUT
|
||||||
'name':
|
|
||||||
'NextCloud',
|
|
||||||
'short_description':
|
|
||||||
'File Hosting Service',
|
|
||||||
'description': [
|
|
||||||
'Nextcloud is a suite of client-server software for creating '
|
|
||||||
'and using file hosting services.'
|
|
||||||
],
|
|
||||||
'icon_url':
|
|
||||||
'/plinth/custom/static/themes/default/icons/nextcloud.png',
|
|
||||||
'clients': [{
|
|
||||||
'name': 'nextcloud',
|
|
||||||
'platforms': [{
|
|
||||||
'type': 'web',
|
|
||||||
'url': '/nextcloud'
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name='custom_shortcuts_file')
|
|
||||||
def fixture_custom_shortcuts_file(load_cfg, tmp_path):
|
|
||||||
"""Fixture to set path for a custom shortcuts file."""
|
|
||||||
load_cfg.config_file = str(tmp_path / 'plinth.conf')
|
|
||||||
return tmp_path / 'custom-shortcuts.json'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name='no_custom_shortcuts_file')
|
@pytest.fixture(name='no_custom_shortcuts_file')
|
||||||
@ -71,13 +46,6 @@ def fixture_empty_custom_shortcuts(custom_shortcuts_file):
|
|||||||
custom_shortcuts_file.write_text(json.dumps({'shortcuts': []}))
|
custom_shortcuts_file.write_text(json.dumps({'shortcuts': []}))
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name='nextcloud_shortcut')
|
|
||||||
def fixture_nextcloud_shortcut(custom_shortcuts_file):
|
|
||||||
"""Create a custom_shortcuts file with NextCloud shortcut."""
|
|
||||||
shortcuts = {'shortcuts': [NEXTCLOUD_SHORTCUT]}
|
|
||||||
custom_shortcuts_file.write_text(json.dumps(shortcuts))
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('no_custom_shortcuts_file')
|
@pytest.mark.usefixtures('no_custom_shortcuts_file')
|
||||||
def test_shortcuts_api_with_no_custom_shortcuts_file():
|
def test_shortcuts_api_with_no_custom_shortcuts_file():
|
||||||
get_shortcuts_as_json()
|
get_shortcuts_as_json()
|
||||||
|
|||||||
@ -24,9 +24,6 @@ import pytest
|
|||||||
|
|
||||||
from plinth.frontpage import Shortcut, add_custom_shortcuts
|
from plinth.frontpage import Shortcut, add_custom_shortcuts
|
||||||
|
|
||||||
from .test_custom_shortcuts import (fixture_custom_shortcuts_file,
|
|
||||||
fixture_nextcloud_shortcut)
|
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user