Passed
Push — main ( fedced...62aa48 )
by Jochen
01:57
created

tests.test_irc_bot_dummy.bot()   A

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
        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