Completed
Push — main ( c8aa67...81e04d )
by Jochen
03:35
created

assert_response_status_code()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 2
dl 0
loc 5
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 tests.helpers import http_client
9
10
11
URL_PATH = '/style_guide/'
12
13
14
# `admin_app` fixture is required because it sets up the database.
15
def test_admin_style_guide_in_debug_mode(admin_app, make_admin_app):
16
    debug_admin_app = make_admin_app(DEBUG=True)
17
    assert_response_status_code(debug_admin_app, 200)
18
19
20
def test_admin_style_guide_in_nondebug_mode(admin_app):
21
    assert_response_status_code(admin_app, 404)
22
23
24
def test_site_style_guide_in_debug_mode(make_site_app, site):
25
    debug_site_app = make_site_app(DEBUG=True)
26
    assert_response_status_code(debug_site_app, 200)
27
28
29
def test_site_style_guide_in_nondebug_mode(site_app, site):
30
    assert_response_status_code(site_app, 404)
31
32
33
# helpers
34
35
36
def assert_response_status_code(app, expected_status_code):
37
    with http_client(app) as client:
38
        response = client.get(URL_PATH)
39
40
    assert response.status_code == expected_status_code
41