コード例 #1
0
ファイル: test_plugins.py プロジェクト: hltbra/oauth2u
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
ファイル: test_plugins.py プロジェクト: globocom/oauth2u
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
ファイル: test_plugins.py プロジェクト: hltbra/oauth2u
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
ファイル: test_plugins.py プロジェクト: hltbra/oauth2u
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
ファイル: test_plugins.py プロジェクト: hltbra/oauth2u
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
ファイル: test_plugins.py プロジェクト: globocom/oauth2u
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
ファイル: test_plugins.py プロジェクト: globocom/oauth2u
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
ファイル: test_plugins.py プロジェクト: globocom/oauth2u
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')