tests.test_irc_bot_dummy.bot()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 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
        commands=[],
21
        channels=channels,
22
    )
23
24
25
@pytest.fixture
26
def bot(config):
27
    bot = create_bot(config)
28
29
    yield bot
30
31
    bot.disconnect('Done.')
32
33
34
def test_fake_channel_joins(bot):
35
    received_signal_data = []
36
37
    @irc_channel_joined.connect
38
    def handle_irc_channel_joined(sender, **data):
39
        received_signal_data.append(data)
40
41
    bot.start()
42
43
    assert received_signal_data == [
44
        {'channel_name': '#one'},
45
        {'channel_name': '#two'},
46
    ]
47