Passed
Branch main (854eb5)
by Jochen
04:24
created

test_category_index_anonymously()   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-2021 Jochen Kupperschmidt
3
:License: Revised BSD (see `LICENSE` file for details)
4
"""
5
6
import pytest
7
8
from tests.helpers import login_user
9
10
from .helpers import find_topic
11
12
13
@pytest.fixture(scope='package')
14
def board_user(make_user):
15
    user = make_user()
16
    login_user(user.id)
17
    yield user
18
19
20
@pytest.fixture(scope='module')
21
def anonymous_client(make_client, site_app):
22
    return make_client(site_app)
23
24
25
@pytest.fixture(scope='module')
26
def logged_in_client(make_client, site_app, board_user):
27
    return make_client(site_app, user_id=board_user.id)
28
29
30
def test_category_index_anonymously(site_app, site, anonymous_client):
31
    url = '/board/'
32
    assert_success_response(anonymous_client, url)
33
34
35
def test_category_index_logged_in(site_app, site, logged_in_client):
36
    url = '/board/'
37
    assert_success_response(logged_in_client, url)
38
39
40
def test_category_view_anonymously(site_app, site, anonymous_client, category):
41
    url = f'/board/categories/{category.slug}'
42
    assert_success_response(anonymous_client, url)
43
44
45
def test_category_view_logged_in(site_app, site, logged_in_client, category):
46
    url = f'/board/categories/{category.slug}'
47
    assert_success_response(logged_in_client, url)
48
49
50
def test_topic_index_anonymously(site_app, site, anonymous_client, topic):
51
    url = '/board/topics'
52
    assert_success_response(anonymous_client, url)
53
54
55
def test_topic_index_logged_in(site_app, site, logged_in_client, topic):
56
    url = '/board/topics'
57
    assert_success_response(logged_in_client, url)
58
59
60
def test_topic_view_anonymously(site_app, site, anonymous_client, topic):
61
    url = f'/board/topics/{topic.id}'
62
    assert_success_response(anonymous_client, url)
63
64
65
def test_topic_view_logged_in(site_app, site, logged_in_client, topic):
66
    url = f'/board/topics/{topic.id}'
67
    assert_success_response(logged_in_client, url)
68
69
70
# helpers
71
72
73
def assert_success_response(client, url):
74
    response = client.get(url)
75
    assert response.status_code == 200
76