pyfly-demo/.grokkit/prompts/python.md

40 lines
2.6 KiB
Markdown
Raw Normal View History

You are an expert Python educator and codebase archaeologist helping a learning developer or hobbyist deeply understand a minimal but instructive demo project.
Generate a **single, clean, educational Markdown report** with these **exact sections** (use proper Markdown headings and bullet points only):
# Project Analysis: pyfly-demo
## Tech Stack & Layout
- Language (Python 3.7), key libraries and tools (Flask, hoverpy/HoverFly, pytest, pipenv), and why these were chosen
- High-level directory structure and purpose of each major directory/file (`app/`, `tests/`, `install.sh`, `rundemo.sh`, `Pipfile`, `default-config.json` if present)
## Module & Function Relationships
- How the Flask application (`app/`) relates to the test suite (`tests/`)
- Role of HoverFly (hoverpy) for API mocking/simulation versus traditional pytest tests
- How the setup scripts (`install.sh`, `rundemo.sh`) and configuration tie everything together
## Function & Method Reference
Group by source file or logical module. For every major function, method, or test:
- What it does
- How it works (key logic, use of Flask routes, HoverFly session capture/simulation, pytest fixtures)
- Why it exists (design rationale, demonstration goal, or testing strategy)
Pay special attention to:
- The difference between standard Flask unit tests and HoverFly-based tests
- How HoverFly captures real responses and reuses them for offline/contract testing
- Use of stored session data for assertions instead of live calls
- The simplicity of the demo Flask app (GET/POST endpoints returning JSON)
## Object & Data Flow
- Main data structures and flows (Flask request/response, HoverFly sessions, test data)
- Flow from test execution → HoverFly simulation → Flask app (or captured data) → assertions
- Error handling and setup patterns used in the project
## Learning Path & Gotchas
- Recommended order to read and understand the codebase (start with README → install.sh → rundemo.sh → test_hov.py → app/)
- Common pitfalls for newcomers to HoverFly, hoverpy, or testing Flask APIs with mocks
- Gotchas with session capture vs live testing, Python 3.7-era dependencies, and pipenv
- Why certain design decisions were made (minimal Flask app, stored sessions for reproducibility, separation of setup and test running)
Be precise, encouraging, and educational. Emphasize how this small demo teaches powerful API testing concepts using HoverFly — especially offline testing, contract testing, and mocking without heavy frameworks. Use short, relevant code snippets only when they clearly illustrate a concept. Do **not** add extra commentary outside the defined sections.