JanKaczmarski / heaven-in-mouth

Food-delivery app WIP
MIT License
1 stars 0 forks source link

Fix tests #87

Closed JanKaczmarski closed 4 months ago

JanKaczmarski commented 4 months ago

I fixed tests. make test works 🥇. Closes #77

JanKaczmarski commented 4 months ago

Proof of my feature working:

  1. Run make init to build database from scratch
    
    ✔ Network heaven-in-mouth_default       Created                                                                                                        0.0s
    ✔ Container heaven-in-mouth-postgres-1  Started                                                                                                        0.2s
    ✔ Container heaven-in-mouth-flask-1     Started                                                                                                        0.2s
    until docker exec heaven-in-mouth-postgres-1 pg_isready ; do sleep 5 ; done
    /var/run/postgresql:5432 - no response
    /var/run/postgresql:5432 - accepting connections
    docker exec heaven-in-mouth-postgres-1 sh -c "psql -U postgres -d heaven_in_mouth < db_setup.sql"
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE
    CREATE TABLE

~/private/heaven-in-mouth: curl localhost:5001/users
[]

2. So the app is working
3. run `make test`
``` bash
docker exec flask_test sh -c "pytest ../tests"
============================= test session starts ==============================
platform linux -- Python 3.9.19, pytest-8.2.2, pluggy-1.5.0
rootdir: /app
plugins: flask-1.3.0
collected 6 items

../tests/test_helpers.py ..                                              [ 33%]
../tests/test_login.py .                                                 [ 50%]
../tests/test_menu_and_dishes.py .                                       [ 66%]
../tests/test_restaurants.py .                                           [ 83%]
../tests/test_users.py .                                                 [100%]

=============================== warnings summary ===============================
../../usr/local/lib/python3.9/site-packages/flask_session/filesystem/filesystem.py:75
  /usr/local/lib/python3.9/site-packages/flask_session/filesystem/filesystem.py:75: DeprecationWarning: FileSystemSessionInterface is deprecated and will be removed in a future release. Instead use the CacheLib backend directly.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================= 6 passed, 1 warning in 0.60s =========================
docker compose -f docker-compose-test.yml --project-name heaven_in_mouth_test down
WARN[0000] /Users/jkaczmarski/private/heaven-in-mouth/docker-compose-test.yml: `version` is obsolete
[+] Running 3/2
 ✔ Container flask_test                  Removed                                                                                                        0.1s
 ✔ Container postgres_test               Removed                                                                                                        0.1s
 ✔ Network heaven_in_mouth_test_default  Removed                                                                                                        0.1s
  1. Check if the main app is still working with curl:
    ~/private/heaven-in-mouth:   curl localhost:5001/users                                                        
    []