feat: implementa sistema de comprovantes com centralizações e PIX
This commit is contained in:
89
tests/test_routes.py
Normal file
89
tests/test_routes.py
Normal file
@@ -0,0 +1,89 @@
|
||||
import pytest
|
||||
from flask import url_for
|
||||
from app import create_app
|
||||
from functions.database import get_db_connection, init_database
|
||||
import os
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
app = create_app()
|
||||
app.config['TESTING'] = True
|
||||
app.config['WTF_CSRF_ENABLED'] = False
|
||||
|
||||
# Criar banco de dados temporário para testes
|
||||
with app.app_context():
|
||||
init_database()
|
||||
|
||||
yield app
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return app.test_client()
|
||||
|
||||
@pytest.fixture
|
||||
def runner(app):
|
||||
return app.test_cli_runner()
|
||||
|
||||
def test_home_page(client):
|
||||
response = client.get('/')
|
||||
assert response.status_code == 302 # Redireciona para login
|
||||
|
||||
def test_login_page(client):
|
||||
response = client.get('/login')
|
||||
assert response.status_code == 200
|
||||
assert b'Login' in response.data
|
||||
|
||||
def test_listar_assinaturas_jornal(client):
|
||||
# Primeiro fazer login
|
||||
client.post('/login', data={
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
})
|
||||
|
||||
response = client.get('/assinaturas/jornal')
|
||||
assert response.status_code == 200
|
||||
assert b'Assinaturas de Jornal' in response.data
|
||||
|
||||
def test_nova_assinatura_jornal(client):
|
||||
# Primeiro fazer login
|
||||
client.post('/login', data={
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
})
|
||||
|
||||
response = client.get('/assinaturas/jornal/novo')
|
||||
assert response.status_code == 200
|
||||
assert b'Registrar Nova Assinatura Anual' in response.data
|
||||
|
||||
def test_listar_militantes(client):
|
||||
# Primeiro fazer login
|
||||
client.post('/login', data={
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
})
|
||||
|
||||
response = client.get('/militantes')
|
||||
assert response.status_code == 200
|
||||
assert b'Militantes' in response.data
|
||||
|
||||
def test_listar_cotas(client):
|
||||
# Primeiro fazer login
|
||||
client.post('/login', data={
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
})
|
||||
|
||||
response = client.get('/cotas')
|
||||
assert response.status_code == 200
|
||||
assert b'Cotas' in response.data
|
||||
|
||||
def test_listar_materiais(client):
|
||||
# Primeiro fazer login
|
||||
client.post('/login', data={
|
||||
'username': 'admin',
|
||||
'password': 'admin123'
|
||||
})
|
||||
|
||||
response = client.get('/materiais')
|
||||
assert response.status_code == 200
|
||||
assert b'Materiais' in response.data
|
||||
Reference in New Issue
Block a user