Completed
Push — main ( dc9c2e...80557c )
by Jochen
05:20
created

news_admin_client()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
import pytest
7
8
from byceps.services.news import channel_service, service as item_service
9
10
from tests.helpers import login_user
11
12
13
@pytest.fixture(scope='package')
14
def news_admin(make_admin):
15
    permission_ids = {
16
        'admin.access',
17
        'news_channel.create',
18
        'news_item.create',
19
        'news_item.publish',
20
        'news_item.update',
21
        'news_item.view',
22
        'news_item.view_draft',
23
    }
24
    admin = make_admin('NewsAdmin', permission_ids)
25
    login_user(admin.id)
26
    return admin
27
28
29
@pytest.fixture(scope='package')
30
def news_admin_client(make_client, admin_app, news_admin):
31
    return make_client(admin_app, user_id=news_admin.id)
32
33
34
@pytest.fixture()
35
def channel(brand):
36
    channel = channel_service.create_channel(
37
        brand.id, 'test-channel-1', 'https://newssite.example/posts/'
38
    )
39
40
    yield channel
41
42
    channel_service.delete_channel(channel.id)
43
44
45
@pytest.fixture()
46
def item(channel, news_admin):
47
    item = item_service.create_item(
48
        channel.id,
49
        'save-the-date',
50
        news_admin.id,
51
        'Save the Date!',
52
        'Party will be next year.',
53
    )
54
55
    yield item
56
57
    item_service.delete_item(item.id)
58