From 6502d01bac98513a1a834101e53b540df00cf9d2 Mon Sep 17 00:00:00 2001 From: QZLin Date: Sun, 8 Sep 2024 11:16:30 +0800 Subject: [PATCH] change to flat-layout --- plugin.py => RootReadme/__init__.py | 0 pyproject.toml | 4 ++-- tests/replace_test.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) rename plugin.py => RootReadme/__init__.py (100%) create mode 100644 tests/replace_test.py diff --git a/plugin.py b/RootReadme/__init__.py similarity index 100% rename from plugin.py rename to RootReadme/__init__.py diff --git a/pyproject.toml b/pyproject.toml index 5f8031c..6467742 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "RootReadme" -version = "0.1" +version = "0.2" readme = "readme.md" classifiers = ["License :: OSI Approved :: MIT License"] @@ -13,4 +13,4 @@ Repository = "https://github.com/QZLin/RootReadme.git" Issues = "https://github.com/QZLin/RootReadme/issues" [project.entry-points."mkdocs.plugins"] -RootReadme = "RootReadme.plugin:RootReadme" +RootReadme = "RootReadme:RootReadme" diff --git a/tests/replace_test.py b/tests/replace_test.py new file mode 100644 index 0000000..3d9dc1e --- /dev/null +++ b/tests/replace_test.py @@ -0,0 +1,26 @@ +import unittest + +positive_cases = [ + '[Getting Started with Sandboxie](docs/Content/GettingStarted.md)', + '[General Usage Tips]( docs/Content/UsageTips.md )' +] +negative_cases = [ + 'docs', + 'docs/', + '/docs/', + '/docs/', + 'example.com/docs/url' +] + + +class MyTestCase(unittest.TestCase): + def test_replace(self): + from plugin import _replacer + for x in positive_cases: + self.assertNotEqual(x, _replacer(x)) + for x in negative_cases: + self.assertEqual(x, _replacer(x)) + + +if __name__ == '__main__': + unittest.main()