Testing the Server
Overview
Terms defined: fixture, heartbeat, test client
Outline
- Add a heartbeat to
server.py
- Wrap the Flask application with a test client that provides an interface like httpx
- Run
pytest test_heartbeat.py
to run tests intest_heartbeat.py
- Rewrite using pytest fixtures in
test_fixtures.py
- Don't duplicate the expected value, since it might change
- Patch database connection function in
test_db.py
instead of creating a fixture - Use the two approaches together in
test_combined.py