Completed
Push — main ( 39501b...4a0798 )
by Jochen
05:29
created

test_when_logged_in()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 3
dl 0
loc 7
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
from tests.helpers import http_client, login_user
7
8
9
def test_when_logged_in(site_app, site, user):
10
    login_user(user.id)
11
12
    response = send_request(site_app, user_id=user.id)
13
14
    assert response.status_code == 200
15
    assert response.mimetype == 'text/html'
16
17
18
def test_when_not_logged_in(site_app, site):
19
    response = send_request(site_app)
20
21
    assert response.status_code == 302
22
    assert 'Location' in response.headers
23
24
25
# helpers
26
27
28
def send_request(app, user_id=None):
29
    url = '/users/me/settings'
30
    with http_client(app, user_id=user_id) as client:
31
        return client.get(url)
32