Testing the Server
Terms defined: fixture, heartbeat, test client
Overview
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.pyto 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.pyinstead of creating a fixture - Use the two approaches together in
test_combined.py