示例#1
0
def test_load_me_now_exception(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = 'my plugin'
    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info('my')
    manager.load_me_later(plugin_info)
    manager.load_me_now('my', 'my special library')
示例#2
0
def test_load_me_now_exception(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = "my plugin"
    with raises(Exception):
        manager = PluginManager(test_plugin)
        plugin_info = make_me_a_plugin_info("my")
        manager.load_me_later(plugin_info)
        manager.load_me_now("my", "my special library")
示例#3
0
def test_load_me_now_with_known_missing_library(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = "my plugin"
    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info(test_plugin)
    manager.load_me_later(plugin_info)
    with raises(Exception):
        manager.load_me_now(test_plugin, library='alien')
示例#4
0
def test_dict_as_plugin_payload():
    manager = PluginManager("test plugin3")

    plugin = PluginInfo("test plugin3", tags=["primary key", "key 1", "key 2"])
    plugin(dict(B=1))

    instance = manager.load_me_now("key 1")
    eq_(instance, dict(B=1))
示例#5
0
def test_load_me_now(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = 'my plugin'
    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info(test_plugin)
    manager.load_me_later(plugin_info)
    actual = manager.load_me_now(test_plugin)
    eq_(actual, custom_class)
示例#6
0
def test_load_me_now(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = "my plugin"
    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info(test_plugin)
    manager.load_me_later(plugin_info)
    actual = manager.load_me_now(test_plugin)
    eq_(actual, custom_class)
    eq_(manager.tag_groups, {"my plugin": "my plugin"})
    eq_(plugin_info, manager.registry["my plugin"][0])
示例#7
0
def test_load_me_now(mock_import):
    custom_class = PluginInfo
    mock_import.return_value = custom_class
    test_plugin = "my plugin"
    manager = PluginManager(test_plugin)
    plugin_info = make_me_a_plugin_info(test_plugin)
    manager.load_me_later(plugin_info)
    actual = manager.load_me_now(test_plugin)
    assert actual == custom_class
    assert manager.tag_groups == {"my plugin": "my plugin"}
    assert plugin_info == manager.registry["my plugin"][0]
示例#8
0
def test_load_me_now_no_key_found():
    test_plugin = 'my plugin'
    manager = PluginManager(test_plugin)
    manager.load_me_now('my', custom_property='here')
示例#9
0
def test_load_me_now_no_key_found():
    test_plugin = "my plugin"
    manager = PluginManager(test_plugin)
    manager.load_me_now("my", custom_property="here")
示例#10
0
def test_load_me_now_no_key_found():
    test_plugin = "my plugin"
    with raises(Exception):
        manager = PluginManager(test_plugin)
        manager.load_me_now("my", custom_property="here")