Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | :Copyright: 2007-2021 Jochen Kupperschmidt |
||
3 | :License: MIT, see LICENSE for details. |
||
4 | """ |
||
5 | |||
6 | import pytest |
||
7 | |||
8 | from syslog2irc.irc import create_bot, IrcChannel, IrcConfig |
||
9 | from syslog2irc.signals import irc_channel_joined |
||
10 | |||
11 | |||
12 | @pytest.fixture |
||
13 | def config(): |
||
14 | channels = {IrcChannel('#one'), IrcChannel('#two')} |
||
15 | |||
16 | return IrcConfig( |
||
17 | server=None, |
||
18 | nickname='nick', |
||
19 | realname='Nick', |
||
20 | channels=channels, |
||
21 | ) |
||
22 | |||
23 | |||
24 | @pytest.fixture |
||
25 | def bot(config): |
||
26 | bot = create_bot(config) |
||
27 | |||
28 | yield bot |
||
29 | |||
30 | bot.disconnect('Done.') |
||
31 | |||
32 | |||
33 | def test_fake_channel_joins(bot): |
||
34 | received_signal_data = [] |
||
35 | |||
36 | @irc_channel_joined.connect |
||
37 | def handle_irc_channel_joined(sender, **data): |
||
38 | received_signal_data.append(data) |
||
39 | |||
40 | bot.start() |
||
41 | |||
42 | assert received_signal_data == [ |
||
43 | {'channel_name': '#one'}, |
||
44 | {'channel_name': '#two'}, |
||
45 | ] |
||
46 |