django-for-runners_ynh/for_runners_ynh/tests/test_readme.py

39 lines
1.3 KiB
Python
Raw Permalink Normal View History

2023-11-26 21:01:26 +01:00
from pathlib import Path
from bx_py_utils.auto_doc import assert_readme_block
2024-08-04 21:05:51 +02:00
from django_yunohost_integration.path_utils import get_project_root
2023-11-26 21:01:26 +01:00
from manageprojects.test_utils.click_cli_utils import invoke_click
from manageprojects.tests.base import BaseTestCase
2024-08-04 21:05:51 +02:00
from for_runners_ynh.cli.dev import cli
from for_runners_ynh.constants import CLI_EPILOG
2023-11-26 21:01:26 +01:00
def assert_cli_help_in_readme(text_block: str, marker: str, readme_path: Path):
text_block = text_block.replace(CLI_EPILOG, '')
text_block = f'```\n{text_block.strip()}\n```'
assert_readme_block(
readme_path=readme_path,
text_block=text_block,
start_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} start ✂✂✂)',
end_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} end ✂✂✂)',
)
class ReadmeTestCase(BaseTestCase):
def test_main_help(self):
stdout = invoke_click(cli, '--help')
self.assert_in_content(
got=stdout,
parts=(
'Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...',
' local-test ',
CLI_EPILOG,
),
)
assert_cli_help_in_readme(
text_block=stdout,
marker='help',
2024-08-04 21:05:51 +02:00
readme_path=get_project_root() / 'doc' / 'ADMIN.md',
2023-11-26 21:01:26 +01:00
)