pkg_resources.iter_entry_points('pgwui.components')]
+def find_pgwui_check_settings():
+ '''Return dict of all pgwui.check_setting entry points, keyed by
+ component
+ '''
+ check_settings = dict()
+ for entry_point in pkg_resources.iter_entry_points('pgwui.check_settings'):
+ callable = entry_point.resolve()
+ check_settings[callable.__name__] = callable
+ return check_settings
+
+
def component_to_key(component):
'''Convert the component to a key used in an ini file's declaration
'''
from pgwui_common import plugin
+# Helper classes
+class MockEntryPoint():
+ def __init__(self, val):
+ self.__name__ = val
+
+ def resolve(self):
+ return self
+
+
+class MockPkgResources():
+ def __init__(self, entry_points):
+ self.entry_points = entry_points
+
+ def iter_entry_points(self, *args):
+ return [MockEntryPoint(name) for name in self.entry_points]
+
+
# find_pgwui_components()
def test_find_pgwui_components(monkeypatch):
'''
entry_points = ['a', 'b', 'c']
- class MockEntryPoint():
- def __init__(self, val):
- self.__name__ = val
+ monkeypatch.setattr(
+ plugin, 'pkg_resources', MockPkgResources(entry_points))
- def resolve(self):
- return self
+ result = plugin.find_pgwui_components()
+
+ assert result == entry_points
- class MockPkgResources():
- def iter_entry_points(*args):
- return [MockEntryPoint(name) for name in entry_points]
+
+# find_pgwui_check_settings
+def test_find_pgwui_check_settings(monkeypatch):
+ '''Returns a dict, keyed by name, of entry points
+ '''
+ entry_points = ['a', 'b', 'c']
monkeypatch.setattr(
- plugin, 'pkg_resources', MockPkgResources())
+ plugin, 'pkg_resources', MockPkgResources(entry_points))
- result = plugin.find_pgwui_components()
+ result = plugin.find_pgwui_check_settings()
- assert result == entry_points
+ assert isinstance(result, dict)
+ assert list(result.keys()).sort() == entry_points.sort()
# component_to_key()