示例#1
0
def test_should_load_plugins_from_directories():
    directory = os.path.abspath(os.path.join(os.path.dirname(__file__), 'plugins_to_test'))

    assert_no_plugin_for('authorization-POST')
    plugins.load_from_directories(directory)

    function = plugins.find('authorization-POST')

    assert 'on_authorization_POST_to_test' == function.__name__
示例#2
0
def test_should_load_plugins_from_directories():
    directory = os.path.abspath(os.path.join(os.path.dirname(__file__), 'plugins_to_test'))

    assert_no_plugin_for('authorization-POST')
    plugins.load_from_directories(directory)

    function = plugins.find('authorization-POST')

    assert 'on_authorization_POST_to_test' == function.__name__
示例#3
0
def test_should_raise_InvalidPlugin_if_trying_to_find_plugin_on_invalid_plugin_name():
    with pytest.raises(plugins.InvalidPlugin) as error:
        plugins.find('NO-SUCH-PLUGIN-NAME')

        assert "Plugin name 'NO-SUCH-PLUGIN-NAME' is invalid. So it's not possible to look for plugins with this name" in str(error)
示例#4
0
def test_should_raise_PluginNotFound_if_trying_to_find_plugin_but_none_registered():
    with pytest.raises(plugins.PluginNotFound) as error:
        plugins.find('authorization-POST')

    assert "No plugin registered to 'authorization-POST'" in str(error)
示例#5
0
def test_should_find_plugin_by_name():
    @plugins.register('authorization-GET')
    def on_authorization_GET(handler):
        handler.write('do nothing')

    assert on_authorization_GET == plugins.find('authorization-GET')
示例#6
0
def test_should_raise_InvalidPlugin_if_trying_to_find_plugin_on_invalid_plugin_name():
    with pytest.raises(plugins.InvalidPlugin) as error:
        plugins.find('NO-SUCH-PLUGIN-NAME')

        assert "Plugin name 'NO-SUCH-PLUGIN-NAME' is invalid. So it's not possible to look for plugins with this name" in str(error)
示例#7
0
def test_should_raise_PluginNotFound_if_trying_to_find_plugin_but_none_registered():
    with pytest.raises(plugins.PluginNotFound) as error:
        plugins.find('authorization-POST')

    assert "No plugin registered to 'authorization-POST'" in str(error)
示例#8
0
def test_should_find_plugin_by_name():
    @plugins.authorization_GET
    def on_authorization_GET(handler):
        handler.write('do nothing')

    assert on_authorization_GET == plugins.find('authorization-GET')