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

test_create()   A

Complexity

Conditions 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nop 2
dl 0
loc 21
rs 9.65
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
from byceps.services.news import channel_service
7
8
9
def test_index_for_brand(news_admin_client, brand, channel):
10
    url = f'/admin/news/brands/{brand.id}'
11
    response = news_admin_client.get(url)
12
    assert response.status_code == 200
13
14
15
def test_view(news_admin_client, channel):
16
    url = f'/admin/news/channels/{channel.id}'
17
    response = news_admin_client.get(url)
18
    assert response.status_code == 200
19
20
21
def test_create_form(news_admin_client, brand):
22
    url = f'/admin/news/for_brand/{brand.id}/channels/create'
23
    response = news_admin_client.get(url)
24
    assert response.status_code == 200
25
26
27
def test_create(news_admin_client, brand):
28
    channel_id = 'test-channel-2'
29
    url_prefix = 'https://24-7-news.example/items/'
30
31
    assert channel_service.find_channel(channel_id) is None
32
33
    url = f'/admin/news/for_brand/{brand.id}/channels'
34
    form_data = {
35
        'channel_id': channel_id,
36
        'url_prefix': url_prefix,
37
    }
38
    response = news_admin_client.post(url, data=form_data)
39
40
    channel = channel_service.find_channel(channel_id)
41
    assert channel is not None
42
    assert channel.id == channel_id
43
    assert channel.brand_id == brand.id
44
    assert channel.url_prefix == url_prefix
45
46
    # Clean up.
47
    channel_service.delete_channel(channel_id)
48