예제 #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')