Skip to content

Commit ed17555

Browse files
committed
Use a real entrypoint-based plugin in tests
1 parent edc4723 commit ed17555

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from flask_pluginengine import Plugin
2+
3+
4+
class FoobarPlugin(Plugin):
5+
"""Foobar plugin
6+
7+
This plugin foobars your foo with your bars.
8+
And doing so is amazing!
9+
"""
10+
11+
version = '69.42'

tests/foobar_plugin/setup.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[metadata]
2+
name = flask-multipass-foobar-plugin
3+
version = 69.13.37
4+
description = Dummy plugin for the tests
5+
6+
[options]
7+
py_modules = foobar_plugin
8+
zip_safe = false
9+
10+
[options.entry_points]
11+
flask_multipass.test.plugins =
12+
foobar = foobar_plugin:FoobarPlugin

tests/foobar_plugin/setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from setuptools import setup
2+
3+
4+
setup()

tests/test_engine.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,23 @@ def init_loader(self, *args, **kwargs):
123123
return engine
124124

125125

126+
def test_real_plugin():
127+
app = PluginFlask(__name__)
128+
app.config['TESTING'] = True
129+
app.config['PLUGINENGINE_NAMESPACE'] = 'flask_multipass.test.plugins'
130+
app.config['PLUGINENGINE_PLUGINS'] = ['foobar']
131+
engine = PluginEngine(app)
132+
assert engine.load_plugins(app)
133+
with app.app_context():
134+
assert len(engine.get_failed_plugins()) == 0
135+
assert list(engine.get_active_plugins()) == ['foobar']
136+
plugin = engine.get_active_plugins()['foobar']
137+
assert plugin.title == 'Foobar plugin'
138+
assert plugin.description == 'This plugin foobars your foo with your bars.\nAnd doing so is amazing!'
139+
assert plugin.version == '69.42'
140+
assert plugin.package_version == '69.13.37'
141+
142+
126143
def test_fail_pluginengine_namespace(flask_app):
127144
"""
128145
Fail if PLUGINENGINE_NAMESPACE is not defined

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ commands = pytest --color=yes --cov {envsitepackagesdir}/flask_pluginengine
99
deps =
1010
pytest
1111
pytest-cov
12+
./tests/foobar_plugin
1213

1314
[testenv:style]
1415
skip_install = true

0 commit comments

Comments
 (0)