create_processor()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nop 0
dl 0
loc 19
rs 9.7
c 0
b 0
f 0
1
"""
2
:Copyright: 2007-2025 Jochen Kupperschmidt
3
:License: MIT, see LICENSE for details.
4
"""
5
6
from weitersager.config import Config, HttpConfig, IrcConfig
7
from weitersager.processor import Processor
8
from weitersager.signals import irc_channel_joined
9
10
11
def test_channel_enabling_on_join_signal():
12
    processor = create_processor()
13
14
    assert '#example1' not in processor.enabled_channel_names
15
    assert '#example2' not in processor.enabled_channel_names
16
17
    irc_channel_joined.send(channel_name='#example1')
18
19
    assert '#example1' in processor.enabled_channel_names
20
    assert '#example2' not in processor.enabled_channel_names
21
22
    irc_channel_joined.send(channel_name='#example2')
23
24
    assert '#example1' in processor.enabled_channel_names
25
    assert '#example2' in processor.enabled_channel_names
26
27
28
def create_processor():
29
    http_config = HttpConfig(
30
        host='127.0.0.1',
31
        port='8080',
32
        api_tokens=set(),
33
        channel_tokens_to_channel_names={},
34
    )
35
36
    irc_config = IrcConfig(
37
        server=None,
38
        nickname='nick',
39
        realname='Nick',
40
        commands=[],
41
        channels=set(),
42
    )
43
44
    config = Config(log_level=None, http=http_config, irc=irc_config)
45
46
    return Processor(config)
47