From c7dcf101075b639f98b637d71762f2eccc74ea11 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sun, 28 Jun 2020 21:13:38 -0500 Subject: [PATCH] New function component_to_key() --- src/pgwui_common/plugin.py | 6 ++++++ tests/test_plugin.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/pgwui_common/plugin.py b/src/pgwui_common/plugin.py index 4577223..d5b97a7 100644 --- a/src/pgwui_common/plugin.py +++ b/src/pgwui_common/plugin.py @@ -30,3 +30,9 @@ def find_pgwui_components(): ''' return [entry_point.resolve().__name__ for entry_point in pkg_resources.iter_entry_points('pgwui.components')] + + +def component_to_key(component): + '''Convert the component to a key used in an ini file's declaration + ''' + return 'pgwui.{}'.format(component) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 4ddc91f..5521436 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -46,3 +46,15 @@ def test_find_pgwui_components(monkeypatch): result = plugin.find_pgwui_components() assert result == entry_points + + +# component_to_key() + +def test_component_to_key(): + '''The return value is as expected + ''' + component = 'pgwui_example' + + result = plugin.component_to_key(component) + + assert result == 'pgwui.' + component -- 2.34.1