Skip to content

resolve warning (and add code coverage if it makes sense) #13

@bbelderbos

Description

@bbelderbos
√ affirmations-api (main) $ make test
uv run pytest --cov=affirmations --cov-report term-missing
========================================================================================================= test session starts =========================================================================================================
platform darwin -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/bbelderbos/code/affirmations-api
configfile: pyproject.toml
plugins: cov-5.0.0, anyio-4.6.0
collected 14 items

tests/test_main.py ..............                                                                                                                                                                                               [100%]

========================================================================================================== warnings summary ===========================================================================================================
affirmations/main.py:17
  /Users/bbelderbos/code/affirmations-api/affirmations/main.py:17: DeprecationWarning:
          on_event is deprecated, use lifespan event handlers instead.

          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).

    @app.on_event("startup")

.venv/lib/python3.12/site-packages/fastapi/applications.py:4495
  /Users/bbelderbos/code/affirmations-api/.venv/lib/python3.12/site-packages/fastapi/applications.py:4495: DeprecationWarning:
          on_event is deprecated, use lifespan event handlers instead.

          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).

    return self.router.on_event(event_type)

tests/test_main.py::test_create_user
  /Users/bbelderbos/code/affirmations-api/affirmations/main.py:29: DeprecationWarning:
          🚨 `obj.from_orm(data)` was deprecated in SQLModel 0.0.14, you should
          instead use `obj.model_validate(data)`.

    db_user = User.from_orm(user)

tests/test_main.py: 11 warnings
  /Users/bbelderbos/code/affirmations-api/affirmations/main.py:74: DeprecationWarning:
          🚨 `obj.from_orm(data)` was deprecated in SQLModel 0.0.14, you should
          instead use `obj.model_validate(data)`.

    db_affirmation = Affirmation.from_orm(affirmation)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.12.6-final-0 ----------
Name                       Stmts   Miss  Cover   Missing
--------------------------------------------------------
affirmations/__init__.py       0      0   100%
affirmations/db.py            10      3    70%   12-13, 17
affirmations/main.py          69      3    96%   19, 59, 109
affirmations/models.py        22      0   100%
--------------------------------------------------------
TOTAL                        101      6    94%

=================================================================================================== 14 passed, 14 warnings in 3.37s ==

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions