From c3970e6f9d1b93945ab2eb3c080121942de1bd2a Mon Sep 17 00:00:00 2001 From: Julien M Date: Thu, 1 Jul 2021 20:26:48 +0200 Subject: [PATCH] Fix about and enlarge md test --- gml_application_schema_toolbox/__about__.py | 5 +-- tests/test_plg_metadata.py | 43 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/gml_application_schema_toolbox/__about__.py b/gml_application_schema_toolbox/__about__.py index af65481a..f6bfe379 100644 --- a/gml_application_schema_toolbox/__about__.py +++ b/gml_application_schema_toolbox/__about__.py @@ -62,9 +62,7 @@ def plugin_metadata_as_dict() -> dict: ) __title__ = __plugin_md__.get("general").get("name") -__title_clean__ = ( - __plugin_md__.get("general").get("name").join(e for e in __title__ if e.isalnum()) -) +__title_clean__ = "".join(e for e in __title__ if e.isalnum()) __uri_homepage__ = __plugin_md__.get("general").get("homepage") __uri_repository__ = __plugin_md__.get("general").get("repository") @@ -87,6 +85,7 @@ def plugin_metadata_as_dict() -> dict: assert isinstance(plugin_md, dict) assert plugin_md.get("general").get("name") == __title__ print("Plugin: " + __title__) + print("Plugin: " + __title_clean__) print("By: " + __author__) print("Version: " + __version__) print("Description: " + __summary__) diff --git a/tests/test_plg_metadata.py b/tests/test_plg_metadata.py index f5c437ec..d6e78ee0 100644 --- a/tests/test_plg_metadata.py +++ b/tests/test_plg_metadata.py @@ -12,6 +12,7 @@ # standard library import unittest +from pathlib import Path # 3rd party from semver import VersionInfo @@ -25,6 +26,48 @@ class TestPluginMetadata(unittest.TestCase): + def test_metadata_types(self): + """Test types.""" + # plugin metadata.txt file + self.assertIsInstance(__about__.PLG_METADATA_FILE, Path) + self.assertTrue(__about__.PLG_METADATA_FILE.is_file()) + + # plugin dir + self.assertIsInstance(__about__.DIR_PLUGIN_ROOT, Path) + self.assertTrue(__about__.DIR_PLUGIN_ROOT.is_dir()) + + # metadata as dict + self.assertIsInstance(__about__.__plugin_md__, dict) + + # general + self.assertIsInstance(__about__.__author__, str) + self.assertIsInstance(__about__.__copyright__, str) + self.assertIsInstance(__about__.__email__, str) + self.assertIsInstance(__about__.__keywords__, list) + self.assertIsInstance(__about__.__license__, str) + self.assertIsInstance(__about__.__summary__, str) + self.assertIsInstance(__about__.__title__, str) + self.assertIsInstance(__about__.__title_clean__, str) + self.assertIsInstance(__about__.__version__, str) + self.assertIsInstance(__about__.__version_info__, tuple) + + # misc + self.assertLessEqual(len(__about__.__title_clean__), len(__about__.__title__)) + + # QGIS versions + self.assertIsInstance( + __about__.__plugin_md__.get("general").get("qgisminimumversion"), str + ) + + self.assertIsInstance( + __about__.__plugin_md__.get("general").get("qgismaximumversion"), str + ) + + self.assertLessEqual( + float(__about__.__plugin_md__.get("general").get("qgisminimumversion")), + float(__about__.__plugin_md__.get("general").get("qgismaximumversion")), + ) + def test_version_semver(self): """Test if version comply with semantic versioning.""" self.assertTrue(VersionInfo.isvalid(__about__.__version__))