23
23
}
24
24
25
25
26
+ @pytest .fixture
27
+ def registry (monkeypatch ):
28
+ new_registry = sirbot .registry .RegistrySingleton ()
29
+ monkeypatch .setattr ('sirbot.core.core.registry' , new_registry )
30
+ monkeypatch .setattr ('sirbot.registry.registry' , new_registry )
31
+
32
+
26
33
def test_bot_is_starting (loop , test_server ):
27
34
bot = sirbot .SirBot (loop = loop )
28
35
loop .run_until_complete (test_server (bot ._app ))
@@ -39,7 +46,7 @@ def test_load_config(loop):
39
46
assert bot .config == config
40
47
41
48
42
- def test_logging_config (loop ):
49
+ def test_logging_config (loop , registry ):
43
50
config = {
44
51
'logging' : {
45
52
'version' : 1 ,
@@ -61,7 +68,7 @@ def test_logging_config(loop):
61
68
assert logging .getLogger ('sirbot' ).level == 40
62
69
63
70
64
- def test_plugin_import (loop , test_server ):
71
+ def test_plugin_import (loop , test_server , registry ):
65
72
bot = sirbot .SirBot (loop = loop , config = CONFIG )
66
73
loop .run_until_complete (test_server (bot ._app ))
67
74
assert bot ._pm .has_plugin ('tests.core.test_plugin.sirbot' )
@@ -76,33 +83,33 @@ def test_plugin_import_error(loop):
76
83
bot ._import_plugins ()
77
84
78
85
79
- def test_initialize_plugins (loop ):
86
+ def test_initialize_plugins (loop , registry ):
80
87
bot = sirbot .SirBot (loop = loop , config = CONFIG )
81
88
assert isinstance (bot ._plugins ['test' ]['plugin' ], PluginTest )
82
89
83
90
84
- def test_plugin_configure (loop , test_server ):
91
+ def test_plugin_configure (loop , test_server , registry ):
85
92
bot = sirbot .SirBot (loop = loop , config = CONFIG )
86
93
loop .run_until_complete (bot ._configure_plugins ())
87
94
88
95
assert bot ._plugins ['test' ]['plugin' ].config == CONFIG ['test' ]
89
96
90
97
91
- def test_start_plugins (loop , test_server ):
98
+ def test_start_plugins (loop , test_server , registry ):
92
99
bot = sirbot .SirBot (loop = loop , config = CONFIG )
93
100
loop .run_until_complete (test_server (bot ._app ))
94
101
assert 'test' in bot ._tasks
95
102
96
103
97
- def test_plugin_task_error (loop , test_server , capsys ):
104
+ def test_plugin_task_error (loop , test_server , registry ):
98
105
config = deepcopy (CONFIG )
99
106
config ['sirbot' ]['plugins' ] = ['tests.core.test_plugin.sirbot_start_error' ]
100
107
bot = sirbot .SirBot (loop = loop , config = config )
101
108
with pytest .raises (ValueError ):
102
109
loop .run_until_complete (test_server (bot ._app ))
103
110
104
111
105
- def test_plugin_priority (loop , test_server ):
112
+ def test_plugin_priority (loop , registry ):
106
113
config = deepcopy (CONFIG )
107
114
config ['test' ]['priority' ] = 80
108
115
config ['test-error' ] = {'priority' : 70 }
0 commit comments