feat(auth): implementar soporte de autenticacion en WebApi
This commit is contained in:
+22
-13
@@ -7,29 +7,38 @@ import pytest
|
||||
@pytest.fixture(scope="module")
|
||||
def client():
|
||||
db_path = tempfile.NamedTemporaryFile(suffix=".db", delete=False).name
|
||||
os.environ["CACU_DATABASE_URL"] = f"sqlite:///{db_path}"
|
||||
isolation = pytest.MonkeyPatch()
|
||||
isolation.setenv("CACU_DATABASE_URL", f"sqlite:///{db_path}")
|
||||
isolation.setenv("AUTH_LITE_ENABLED", "false")
|
||||
|
||||
from core.cacu.base import CaCuModel
|
||||
from core.cacu.models import Paciente
|
||||
from persistance.db import get_cacu_engine
|
||||
from persistance.settings import settings
|
||||
|
||||
isolation.setattr(settings, "cacu_database_url", f"sqlite:///{db_path}")
|
||||
get_cacu_engine.cache_clear()
|
||||
engine = get_cacu_engine()
|
||||
CaCuModel.metadata.create_all(engine)
|
||||
try:
|
||||
CaCuModel.metadata.create_all(engine)
|
||||
|
||||
from sqlmodel import Session
|
||||
from sqlmodel import Session
|
||||
|
||||
with Session(engine) as session:
|
||||
session.add(Paciente(pac_id_hospital="H-1", pac_sexo="Femenino"))
|
||||
session.commit()
|
||||
with Session(engine) as session:
|
||||
session.add(Paciente(pac_id_hospital="H-1", pac_sexo="Femenino"))
|
||||
session.commit()
|
||||
|
||||
from webapi import create_app
|
||||
from webapi import create_app
|
||||
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as client:
|
||||
yield client
|
||||
|
||||
os.unlink(db_path)
|
||||
app = create_app()
|
||||
app.config.update(TESTING=True)
|
||||
with app.test_client() as client:
|
||||
yield client
|
||||
finally:
|
||||
engine.dispose()
|
||||
get_cacu_engine.cache_clear()
|
||||
os.unlink(db_path)
|
||||
isolation.undo()
|
||||
|
||||
|
||||
def test_health(client):
|
||||
|
||||
Reference in New Issue
Block a user