diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-05-08 10:54:43 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-05-08 11:02:53 -0500 |
commit | d3604e29205c96877a6eb3fd5b1189ee0742382b (patch) | |
tree | b374c13cfc0b5d2cdab791dfa7b1a1e980e3a1b2 /mediagoblin/tests/test_pluginapi.py | |
parent | 7fadc33b80afb3452f8bc7199145c827abfc03b5 (diff) | |
download | mediagoblin-d3604e29205c96877a6eb3fd5b1189ee0742382b.tar.lz mediagoblin-d3604e29205c96877a6eb3fd5b1189ee0742382b.tar.xz mediagoblin-d3604e29205c96877a6eb3fd5b1189ee0742382b.zip |
Unit tests for plugins defining their own config_spec.ini!
This commit sponsored by David Ahmed. Thank you!
Diffstat (limited to 'mediagoblin/tests/test_pluginapi.py')
-rw-r--r-- | mediagoblin/tests/test_pluginapi.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_pluginapi.py b/mediagoblin/tests/test_pluginapi.py index f03e868f..809b5ce9 100644 --- a/mediagoblin/tests/test_pluginapi.py +++ b/mediagoblin/tests/test_pluginapi.py @@ -18,9 +18,12 @@ import sys from configobj import ConfigObj import pytest +import pkg_resources +from validate import VdtTypeError from mediagoblin import mg_globals from mediagoblin.init.plugins import setup_plugins +from mediagoblin.init.config import read_mediagoblin_config from mediagoblin.tools import pluginapi @@ -294,3 +297,29 @@ def test_hook_transform(): assert pluginapi.hook_transform( "expand_tuple", (-1, 0)) == (-1, 0, 1, 2, 3) + + +def test_plugin_config(): + """ + Make sure plugins can set up their own config + """ + config, validation_result = read_mediagoblin_config( + pkg_resources.resource_filename( + 'mediagoblin.tests', 'appconfig_plugin_specs.ini')) + + pluginspec_section = config['plugins'][ + 'mediagoblin.tests.testplugins.pluginspec'] + assert pluginspec_section['some_string'] == 'not blork' + assert pluginspec_section['dont_change_me'] == 'still the default' + + # Make sure validation works... this should be an error + assert isinstance( + validation_result[ + 'plugins'][ + 'mediagoblin.tests.testplugins.pluginspec'][ + 'some_int'], + VdtTypeError) + + # the callables thing shouldn't really have anything though. + assert len(config['plugins'][ + 'mediagoblin.tests.testplugins.callables1']) == 0 |