| 1 |
import os |
| 2 |
|
| 3 |
extra_plugin_dir = os.path.join( |
| 4 |
os.path.dirname(os.path.realpath(__file__)), "dependent_plugins" |
| 5 |
) |
| 6 |
|
| 7 |
|
| 8 |
def test_if_all_loaded_by_default(testbot): |
| 9 |
plug_names = testbot.bot.plugin_manager.get_all_active_plugin_names() |
| 10 |
assert "Single" in plug_names |
| 11 |
assert "Parent1" in plug_names |
| 12 |
assert "Parent2" in plug_names |
| 13 |
|
| 14 |
|
| 15 |
def test_single_dependency(testbot): |
| 16 |
pm = testbot.bot.plugin_manager |
| 17 |
for p in ("Single", "Parent1", "Parent2"): |
| 18 |
pm.deactivate_plugin(p) |
| 19 |
|
| 20 |
# everything should be gone |
| 21 |
plug_names = pm.get_all_active_plugin_names() |
| 22 |
assert "Single" not in plug_names |
| 23 |
assert "Parent1" not in plug_names |
| 24 |
assert "Parent2" not in plug_names |
| 25 |
|
| 26 |
pm.activate_plugin("Single") |
| 27 |
|
| 28 |
# it should have activated the dependent plugin 'Parent1' only |
| 29 |
plug_names = pm.get_all_active_plugin_names() |
| 30 |
assert "Single" in plug_names |
| 31 |
assert "Parent1" in plug_names |
| 32 |
assert "Parent2" not in plug_names |
| 33 |
|
| 34 |
|
| 35 |
def test_double_dependency(testbot): |
| 36 |
pm = testbot.bot.plugin_manager |
| 37 |
all = ("Double", "Parent1", "Parent2") |
| 38 |
for p in all: |
| 39 |
pm.deactivate_plugin(p) |
| 40 |
|
| 41 |
pm.activate_plugin("Double") |
| 42 |
plug_names = pm.get_all_active_plugin_names() |
| 43 |
for p in all: |
| 44 |
assert p in plug_names |
| 45 |
|
| 46 |
|
| 47 |
def test_dependency_retrieval(testbot): |
| 48 |
assert "youpi" in testbot.exec_command("!depfunc") |
| 49 |
|
| 50 |
|
| 51 |
def test_direct_circular_dependency(testbot): |
| 52 |
plug_names = testbot.bot.plugin_manager.get_all_active_plugin_names() |
| 53 |
assert "Circular1" not in plug_names |
| 54 |
|
| 55 |
|
| 56 |
def test_indirect_circular_dependency(testbot): |
| 57 |
plug_names = testbot.bot.plugin_manager.get_all_active_plugin_names() |
| 58 |
assert "Circular2" not in plug_names |
| 59 |
assert "Circular3" not in plug_names |
| 60 |
assert "Circular4" not in plug_names |
| 61 |
|
| 62 |
|
| 63 |
def test_chained_dependency(testbot): |
| 64 |
plug_names = testbot.bot.plugin_manager.get_all_active_plugin_names() |
| 65 |
assert "Chained1" in plug_names |
| 66 |
assert "Chained2" in plug_names |
| 67 |
assert "Chained3" in plug_names |