0–5 min
Real Hook
5–25 min
Core Concept
25–45 min
Live Coding
45–55 min
You Code It
55–60 min
Cheat Sheet
🔥 Real-World Hook (0–5 min)

Your first day at a company: senior hands you a codebase, a Jira ticket, and says "make a PR by end of day." No guidance. No step-by-step.

Today that's exactly what happens. You get a real git workflow — feature branches, pull requests, code review. You write pytest tests. You fix a deliberately broken feature. This is the gap between "I know Python" and "I'm ready to work at a company."

🌳 Git-Flow + pytest in 1 Hour (5–25 min)

💡 Industry Git Workflow

Never commit to main. Create a feature branch — git checkout -b feature/add-borrow-limit. Write code. Write tests. Push branch. Open PR. Get reviewed. Merge.

This is how every company from 5-person startups to Google works. Get used to it today.

💻 Live Coding — Testing with pytest (25–45 min)

# pip install pytest pytest-django

# conftest.py (tells pytest about Django settings)
import pytest
from django.test import RequestFactory

@pytest.fixture
def api_client():
    from rest_framework.test import APIClient
    return APIClient()

@pytest.fixture
def sample_student(db):
    from students.models import Student
    return Student.objects.create(
        name="Priya", email="p@test.com", dept="CS", gpa=3.9
    )
# tests/test_students.py
import pytest

@pytest.mark.django_db
def test_student_list(api_client, sample_student):
    res = api_client.get("/api/students/")
    assert res.status_code == 200
    assert len(res.json()) == 1

@pytest.mark.django_db
def test_create_student(api_client):
    data = {"name":"Ravi","email":"r@test.com","dept":"IT","gpa":3.2}
    res = api_client.post("/api/students/", data, format="json")
    assert res.status_code == 201
    assert res.json()["name"] == "Ravi"

@pytest.mark.django_db
def test_gpa_validation(api_client):
    # GPA can't be negative
    data = {"name":"Bad","email":"b@test.com","dept":"CS","gpa":-1.0}
    res = api_client.post("/api/students/", data, format="json")
    assert res.status_code == 400    # should reject

# Run: pytest -v
# ✓ test_student_list PASSED
# ✓ test_create_student PASSED
# ✓ test_gpa_validation PASSED

🍴 Git Workflow — Feature Branch → PR

# Industry standard: never commit directly to main

git checkout -b feature/add-borrow-limit

# ... write code and tests ...

git add .
git commit -m "feat: add borrow limit of 3 books per member"

git push origin feature/add-borrow-limit

# GitHub: Create Pull Request
# PR title: "feat: add borrow limit"
# Description: What changed, why, how to test
# Request review from a classmate

# After approval: merge to main
git checkout main
git pull
git branch -d feature/add-borrow-limit
🎯 Industry Simulation — Your Final Challenge (45–55 min)
  1. Create branch: git checkout -b feature/search-enhancement
  2. Add a custom search endpoint: GET /api/students/search/?q=term that searches name AND email
  3. Write 3 pytest tests for this endpoint: empty query, matching results, no results
  4. Run pytest -v — all 3 must pass
  5. Commit with proper message: feat: add multi-field student search endpoint
  6. Push branch, open a PR on GitHub, assign a classmate as reviewer
  7. Show: PR open, green tests, reviewer assigned. You are ready for Day 1 at a company.

📄 Day 15 Cheat Sheet — pytest + Git-Flow

pytest

pip install pytest pytest-djangoInstall
def test_name(...):Test function
assert x == yAssert equality
@pytest.mark.django_dbEnable DB access
@pytest.fixtureReusable setup
pytest -vRun verbose

DRF Test Client

APIClient()Test HTTP client
client.get("/url/")GET request
client.post("/url/", data, format="json")POST JSON
client.force_authenticate(user)Login in test
res.status_codeHTTP status
res.json()Response body

Git Feature Branch

git checkout -b feature/nameCreate + switch
git branchList branches
git push origin feature/namePush branch
git checkout mainSwitch to main
git merge feature/nameMerge
git branch -d feature/nameDelete local

Commit Convention

feat: add searchNew feature
fix: handle empty queryBug fix
test: add search testsTests only
docs: update READMEDocumentation
refactor: simplify filterCode cleanup
chore: update depsMaintenance