Passed
Push — main ( a0d2b9...52c0ea )
by Jochen
04:32
created

make_channel()   A

Complexity

Conditions 2

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
nop 0
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2022 Jochen Kupperschmidt
3
:License: Revised BSD (see `LICENSE` file for details)
4
"""
5
6
from typing import Optional
7
8
import pytest
9
10
from byceps.services.news import channel_service
11
from byceps.services.news.transfer.models import Channel, ChannelID
12
from byceps.services.site.transfer.models import SiteID
13
from byceps.typing import BrandID
14
15
from tests.helpers import generate_token
16
17
18
@pytest.fixture
19
def make_channel():
20
    def _wrapper(
21
        brand_id: BrandID,
22
        channel_id: Optional[ChannelID] = None,
23
        *,
24
        url_prefix: Optional[str] = None,
25
        announcement_site_id: Optional[SiteID] = None,
26
    ) -> Channel:
27
        if channel_id is None:
28
            channel_id = ChannelID(generate_token())
29
30
        return channel_service.create_channel(
31
            brand_id,
32
            channel_id,
33
            url_prefix=url_prefix,
34
            announcement_site_id=announcement_site_id,
35
        )
36
37
    return _wrapper
38