From 76fbfeee8718842d19a43642d090ecfedc80e9fa Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Mon, 19 Sep 2022 08:49:01 +0200 Subject: [PATCH 1/2] expand tests --- tests/test_project_setup.py | 52 +++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tests/test_project_setup.py b/tests/test_project_setup.py index f407fa0..eae8e81 100644 --- a/tests/test_project_setup.py +++ b/tests/test_project_setup.py @@ -1,9 +1,12 @@ +import difflib import os import shutil import subprocess from pathlib import Path import tomli +from bx_django_utils.filename import clean_filename +from bx_py_utils.path import assert_is_dir, assert_is_file from django_tools.unittest_utils.project_setup import check_editor_config import django_yunohost_integration @@ -38,19 +41,64 @@ def test_version(): ) -def test_poetry_check(): +def poetry_check_output(*args): poerty_bin = shutil.which('poetry') output = subprocess.check_output( - [poerty_bin, 'check'], + (poerty_bin,) + args, text=True, env=os.environ, stderr=subprocess.STDOUT, cwd=str(PACKAGE_ROOT), ) print(output) + return output + + +def test_poetry_check(): + output = poetry_check_output('check') assert output == 'All set!\n' +def test_requirements_txt(): + requirements_txt = PACKAGE_ROOT / 'conf' / 'requirements.txt' + assert_is_file(requirements_txt) + + output = poetry_check_output('export', '-f', 'requirements.txt') + assert 'Warning' not in output + + current_content = requirements_txt.read_text() + + diff = '\n'.join( + difflib.unified_diff( + current_content.splitlines(), + output.splitlines(), + fromfile=str(requirements_txt), + tofile='FRESH EXPORT', + ) + ) + print(diff) + assert diff == '', f'{requirements_txt} is not up-to-date! (Hint: call: "make update")' + + +def test_screenshot_filenames(): + """ + https://forum.yunohost.org/t/yunohost-bot-cant-handle-spaces-in-screenshots/19483 + """ + screenshot_path = PACKAGE_ROOT / 'doc' / 'screenshots' + assert_is_dir(screenshot_path) + renamed = [] + for file_path in screenshot_path.iterdir(): + file_name = file_path.name + if file_name.startswith('.'): + continue + cleaned_name = clean_filename(file_name) + if cleaned_name != file_name: + new_path = file_path.with_name(cleaned_name) + file_path.rename(new_path) + renamed.append(f'{file_name!r} renamed to {cleaned_name!r}') + assert not renamed, f'Bad screenshots file names found: {", ".join(renamed)}' + + def test_check_editor_config(): check_editor_config(package_root=PACKAGE_ROOT) From b63c420774836c9a8792d7719573fdc6c85789c2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 19 Sep 2022 06:49:10 +0000 Subject: [PATCH 2/2] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index feee58f..3e1bdba 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example Pull requests welcome ;) -**Shipped version:** 0.4.0rc1~ynh1 +**Shipped version:** 0.4.0~ynh1 ## Disclaimers / important information diff --git a/README_fr.md b/README_fr.md index cfba721..cfe6e6e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,7 @@ Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example Pull requests welcome ;) -**Version incluse :** 0.4.0rc1~ynh1 +**Version incluse :** 0.4.0~ynh1 ## Avertissements / informations importantes