From 6eff6d26981f25734fc3819525da3d175e608497 Mon Sep 17 00:00:00 2001 From: CuberHuber Date: Fri, 24 Jan 2025 11:42:18 +0300 Subject: [PATCH] feature(tests): added test for readme.md title (#55) Solved: #55 --- tests/test_plugin_readme.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/test_plugin_readme.py b/tests/test_plugin_readme.py index 9bac640..09285ae 100644 --- a/tests/test_plugin_readme.py +++ b/tests/test_plugin_readme.py @@ -8,14 +8,27 @@ @pytest.mark.pre_set class TestPluginREADME: - def test_badges_name(self, fix_plugin_manifest): + @pytest.fixture(scope="class", autouse=True) + def readme_content(self) -> str: + with open(Path(__file__).parent.parent / 'readme.md', 'r') as file: + readme_content = file.read() + return readme_content + + def test_badges_name(self, fix_plugin_manifest, readme_content): """Проверка соответствие имен репозитория в ссылках на шильдики GitHub""" print(fix_plugin_manifest.plugin_name) badge_pattern = rf'\[\!\[.*?\]\(https://github\.com/S3-Platform-Inc/{fix_plugin_manifest.plugin_name.replace("_", "-")}/actions/workflows/.*?\.yml/badge\.svg\)\]' - with open(Path(__file__).parent.parent / 'readme.md', 'r') as file: - readme_content = file.read() - found_lines = re.findall(badge_pattern, readme_content, re.MULTILINE) assert len(found_lines) == 3, "Обновите readme.md файл. Укажите валидный url для GitHub Badges" + + def test_title(self, fix_plugin_manifest, readme_content): + title_pattern = r'^# S3 Platform Plugin Template' + + matched = re.match(title_pattern, readme_content) + + if fix_plugin_manifest.plugin_name == "s3_platform_plugin_template": + assert matched + else: + assert not matched, "Измените название плагина в readme.md файле"