prijatelilab / PrijateliTree

A FastAPI application used to play lab games and collect survey data.
MIT License
1 stars 0 forks source link

Add testing framework #118

Closed michplunkett closed 10 months ago

michplunkett commented 10 months ago

Describe Your Changes

Add testing framework, GitHub Action, and baseline test.

Relevant Information

https://sqlmodel.tiangolo.com/tutorial/fastapi/tests/

Checklist Before Requesting a Review

(prijatelitree-py3.11) michaelp@MacBook-Air-18 PrijateliTree % make test
docker-compose up -d
[+] Building 0.0s (0/0)                                                                                                                                                                    docker:desktop-linux
[+] Running 2/0
 ✔ Container prijatelitree-postgres-1  Running                                                                                                                                                             0.0s 
 ✔ Container prijatelitree-web-1       Running                                                                                                                                                             0.0s 
ENV=testing docker-compose run --rm web pytest -vsx ./prijateli_tree/tests/;
[+] Building 0.0s (0/0)                                                                                                                                                                    docker:desktop-linux
[+] Creating 1/0
 ✔ Container prijatelitree-postgres-1  Running                                                                                                                                                             0.0s 
[+] Building 0.0s (0/0)                                                                                                                                                                    docker:desktop-linux
DEBUG:  Routers loaded and static files mounted.
============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.11.4, pytest-7.4.3, pluggy-1.3.0 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: /usr/src/app
plugins: anyio-3.7.1
collected 1 item                                                                                                                                                                                               

prijateli_tree/tests/test_home.py::test_home_page DEBUG:    Using selector: EpollSelector
INFO:   HTTP Request: GET http://testserver/ "HTTP/1.1 200 OK"
PASSED

=============================================================================================== warnings summary ===============================================================================================
../../local/lib/python3.11/site-packages/passlib/utils/__init__.py:854
  /usr/local/lib/python3.11/site-packages/passlib/utils/__init__.py:854: DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
    from crypt import crypt as _crypt

prijateli_tree/app/database.py:34
  /usr/src/app/prijateli_tree/app/database.py:34: MovedIn20Warning: The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    Base = declarative_base()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================== 1 passed, 2 warnings in 0.03s =========================================================================================
(prijatelitree-py3.11) michaelp@MacBook-Air-18 PrijateliTree % 
...
2023-12-24 16:13:55 INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2023-12-24 16:13:55 INFO:     Started reloader process [1] using WatchFiles
2023-12-24 16:13:56 DEBUG:      Routers loaded and static files mounted.
2023-12-24 16:13:56 INFO:     Started server process [8]
2023-12-24 16:13:56 INFO:     Waiting for application startup.
2023-12-24 16:13:56 INFO:     Application startup complete.
2023-12-24 16:14:08 INFO:     192.168.65.1:65143 - "GET / HTTP/1.1" 200 OK
2023-12-24 16:14:08 INFO:     192.168.65.1:65143 - "GET /css/bootstrap.min.css HTTP/1.1" 200 OK
2023-12-24 16:14:08 INFO:     192.168.65.1:65144 - "GET /js/bootstrap.bundle.min.js HTTP/1.1" 200 OK
2023-12-24 16:14:08 INFO:     192.168.65.1:65148 - "GET /js/dataTables.bootstrap5.min.js HTTP/1.1" 304 Not Modified
2023-12-24 16:14:08 INFO:     192.168.65.1:65146 - "GET /js/jquery.dataTables.min.js HTTP/1.1" 200 OK