Beispiel #1
0
import pytest
from fastapi_sqlalchemy import db, DBSessionMiddleware

from app.crud.topic import CRUDTopic
from app.main import app
from app.models.topic import Topic


db_url = 'sqlite:///./test.db'

app.add_middleware(DBSessionMiddleware, db_url=db_url)


@pytest.mark.usefixtures('create_topic_dummy', 'tear_down')
def test_get__model_returns_a_model_instance():
    crud = CRUDTopic()
    with db():
        result = crud.get(1)
    assert isinstance(result, Topic)


@pytest.mark.usefixtures('create_topic_dummy', 'tear_down')
def test_get__model_attr_is_the_same_created_by_fixture():
    crud = CRUDTopic()
    with db():
        result = crud.get(1)
    assert result.name == 'topic_xpto'
Beispiel #2
0
 def teardown_class(cls):
     app.add_middleware(DBSessionMiddleware, db_url=os.getenv("DB_URL"))
Beispiel #3
0
        if file not in DISEASE_HISTORY_STATE_FILES:
            if time_life_file > 3600:
                os.remove(CLEARED_DIR + file)


app.include_router(default.router)
app.include_router(hospitals.router, tags=['hospital'])
app.include_router(auth.router, prefix='/auth', tags=['auth'])
app.include_router(disease_history.router, prefix='/history', tags=['history'])
app.include_router(doctors.router, tags=['doctors'])
app.include_router(patients.router, tags=['patients'])
app.include_router(schedule.router, tags=['schedules'])
app.mount("/static", StaticFiles(directory="static"), name='static')

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.mount("/assets", StaticFiles(directory="static/assets"), name='assets')
app.mount("/icons", StaticFiles(directory="static/icons"), name='assets')
app.mount("/profile",
          StaticFiles(directory="static/assets/assets"),
          name='assets')

if __name__ == '__main__':
    uvicorn.run("run:app", host='0.0.0.0', port=80)
Beispiel #4
0
 def setup_class(cls):
     app.add_middleware(DBSessionMiddleware, db_url=os.getenv("DB_TEST_URL"))