~homeworkprod/byceps

ref: 43bf3630475839afde6e691f0ac561dcb01aaba6 byceps/testfixtures/board.py -rw-r--r-- 1.2 KiB
43bf3630 — Jochen Kupperschmidt Upgrade pytest on Travis CI to get v3.3 rather than v3.0 provided by default 4 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
"""
testfixtures.board
~~~~~~~~~~~~~~~~~~

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

from byceps.services.board import board_service, category_service, \
    posting_service, topic_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 = 'category-{}'.format(number)

    if title is None:
        title = 'Kategorie {}'.format(number)

    if description is None:
        description = 'Hier geht es um Kategorie {}'.format(number)

    return category_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 = 'Thema {}'.format(number)

    if body is None:
        body = 'Inhalt von Thema {}'.format(number)

    return topic_service.create_topic(category_id, creator_id, title, body)


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

    return posting_service.create_posting(topic, creator_id, body)