tests.http.conftest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A make_server() 0 21 2
1
"""
2
:Copyright: 2007-2025 Jochen Kupperschmidt
3
:License: MIT, see LICENSE for details.
4
"""
5
6
from threading import Thread
7
8
import pytest
9
10
from weitersager.config import HttpConfig
11
from weitersager.http import create_server
12
13
14
@pytest.fixture
15
def make_server():
16
    # Per default, bind to localhost on random user port.
17
    def _wrapper(host='', port=0, *, api_tokens=None):
18
        if api_tokens is None:
19
            api_tokens = set()
20
        config = HttpConfig(
21
            host,
22
            port,
23
            api_tokens=api_tokens,
24
            channel_tokens_to_channel_names={},
25
        )
26
27
        server = create_server(config)
28
29
        thread = Thread(target=server.handle_request)
30
        thread.start()
31
32
        return server
33
34
    return _wrapper
35