~homeworkprod/byceps

ref: a3214d27456b4060727966ca1ad520a92edaa6b2 byceps/testfixtures/board.py -rw-r--r-- 1.3 KiB
a3214d27 — Jochen Kupperschmidt Make tourney avatar path depend on party path, but non-configurable besides that 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
testfixtures.board
~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from byceps.services.board import (
    board_service,
    category_command_service,
    posting_command_service,
    topic_command_service,
)


def create_board(brand_id, board_id):
    return board_service.create_board(brand_id, board_id)


def create_category(
    board_id, *, number=1, slug=None, title=None, description=None
):
    if slug is None:
        slug = f'category-{number}'

    if title is None:
        title = f'Kategorie {number}'

    if description is None:
        description = f'Hier geht es um Kategorie {number}'

    return category_command_service.create_category(
        board_id, slug, title, description
    )


def create_topic(category_id, creator_id, *, number=1, title=None, body=None):
    if title is None:
        title = f'Thema {number}'

    if body is None:
        body = f'Inhalt von Thema {number}'

    topic, _ = topic_command_service.create_topic(
        category_id, creator_id, title, body
    )

    return topic


def create_posting(topic_id, creator_id, *, number=1, body=None):
    if body is None:
        body = f'Inhalt von Beitrag {number}.'

    posting, event = posting_command_service.create_posting(
        topic_id, creator_id, body
    )

    return posting