feat: monta app final (main.py) e Docker end-to-end
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_raiz_sem_login_pede_credenciais():
|
||||
resposta = client.get("/", follow_redirects=False)
|
||||
assert resposta.status_code == 401
|
||||
|
||||
|
||||
def test_raiz_redireciona_para_clientes_com_login(monkeypatch):
|
||||
from app.routers import clientes as router_clientes
|
||||
|
||||
monkeypatch.setattr(router_clientes.db_clientes, "listar_clientes", lambda busca=None, limite=100: [])
|
||||
import base64
|
||||
token = base64.b64encode(b"admin:teste123").decode()
|
||||
resposta = client.get("/", headers={"Authorization": f"Basic {token}"}, follow_redirects=False)
|
||||
assert resposta.status_code == 307
|
||||
assert resposta.headers["location"] == "/clientes"
|
||||
Reference in New Issue
Block a user