Tutorials for Development - CapstoneNutritionTeam/nutritrack-capstone GitHub Wiki
Nutrition Calculator Project Documentation
Flask Python Learning Resources
Docker Learning Resources
CI/CD Setup Overview
requirements.txt
1. Flask
pytest
tests/test_app.py
2. Test File: from app import app
def test_home_route():
client = app.test_client()
response = client.get('/')
assert response.status_code == 200
assert b"Welcome" in response.data
.github/workflows/python-app.yml
3. GitHub Actions Workflow: name: Run Pytest
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
pytest
4. Example GitHub Actions Output (Success)
Run pytest
============================= test session starts ==============================
platform linux -- Python 3.10.4, pytest-7.4.2, pluggy-1.2.0
rootdir: /home/runner/work/nutrition-app/nutrition-app
collected 1 item
tests/test_app.py . [100%]
============================== 1 passed in 0.45s ===============================
✅ Job succeeded
This documentation summarizes the key resources and configuration files used for developing and automating tests in our Flask Nutrition Calculator project.