tests.test_processor_channel_enabling   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_channel_enabling_on_join_signal() 0 21 1
A create_processor() 0 12 1
1
"""
2
:Copyright: 2007-2021 Jochen Kupperschmidt
3
:License: MIT, see LICENSE for details.
4
"""
5
6
from syslog2irc.config import Config
7
from syslog2irc.irc import IrcConfig
8
from syslog2irc.main import Processor
9
from syslog2irc.network import Port, TransportProtocol
10
from syslog2irc.routing import Route
11
from syslog2irc.signals import irc_channel_joined
12
13
14
def test_channel_enabling_on_join_signal():
15
    routes = {
16
        Route(Port(514, TransportProtocol.UDP), '#example1'),
17
        Route(Port(514, TransportProtocol.UDP), '#example2'),
18
        Route(Port(55514, TransportProtocol.UDP), '#example2'),
19
    }
20
21
    processor = create_processor(routes)
22
23
    assert not processor.router.is_channel_enabled('#example1')
24
    assert not processor.router.is_channel_enabled('#example2')
25
26
    irc_channel_joined.send(channel_name='#example1')
27
28
    assert processor.router.is_channel_enabled('#example1')
29
    assert not processor.router.is_channel_enabled('#example2')
30
31
    irc_channel_joined.send(channel_name='#example2')
32
33
    assert processor.router.is_channel_enabled('#example1')
34
    assert processor.router.is_channel_enabled('#example2')
35
36
37
def create_processor(routes):
38
    irc_config = IrcConfig(
39
        server=None,
40
        nickname='nick',
41
        realname='Nick',
42
        commands=[],
43
        channels=set(),
44
    )
45
46
    config = Config(log_level=None, irc=irc_config, routes=routes)
47
48
    return Processor(config)
49