-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_routes - Copia.py
More file actions
38 lines (31 loc) · 1.15 KB
/
test_routes - Copia.py
File metadata and controls
38 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pytest
from app import app, models
@pytest.fixture
def client():
with app.test_client() as client:
yield client
def test_index_not_logged_in(client):
response = client.get('/')
assert b'Login' in response.data
def test_index_not_logged_in(client):
response = client.get('/')
assert response.status_code == 302
assert response.headers['Location'] == '/login'
def test_login(client):
response = client.post('/login', data=dict(
username='savio',
password='savio'
), follow_redirects=True)
assert 'Lista de Usuários' in response.data.decode('utf-8')
def test_register(client):
response = client.post('/register', data=dict(
username='new_user',
password='new_password'
), follow_redirects=False)
assert response.status_code == 302
assert response.location == '/login' # Verifica se o redirecionamento está indo para a página inicial
def test_delete(client):
with client.session_transaction() as sess:
sess['username'] = 'savio'
response = client.get('/delete/teste2')
assert b'teste' not in response.data