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

tests.integration.blueprints.common.user.settings.test_views   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

3 Functions

Rating   Name   Duplication   Size   Complexity  
A send_request() 0 4 2
A test_when_logged_in() 0 7 1
A test_when_not_logged_in() 0 5 1
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