Skip to main content
In this final section, we’ll master GitHub Copilot’s core features and apply them to build a small, practical project that solves a real compliance need. In this lesson we will:
  • Introduce the project and requirements.
  • Create a new Python project.
  • Build a fake-data generator API with inline code documentation.
  • Add unit tests to verify behavior.
  • Produce API documentation so others can use the tool.
  • Demonstrate how AI pair-programming fits into the workflow.
Your company requirement is simple but strict: you may no longer use real customer data for testing. Customer privacy must be protected at all times.
Do not use, copy, or expose any real customer PII in development, test environments, or CI logs. This project provides safe, realistic mock data so teams can validate behavior without risking compliance violations.
A slide titled "What We'll Build" showing a person/documents icon on the left with a red X over "Customer Data." An arrow leads to a computer screen labeled "Software Testing" with gears indicating configuration or automation.
We don’t need real data to validate functionality. Instead, we’ll build a fake-data generator that produces realistic mock records so developers and testers can exercise applications without exposing customer information. Project summary
  • Goal: Create an API that returns realistic mock user data in multiple formats (JSON, CSV, downloadable text files).
  • Stack: FastAPI (Python), pytest (unit testing), and standard libraries for serialization.
  • Outputs: Configurable fake records for frontend, batch processing, and download pipelines.
Why this helps
  • Preserves privacy and regulatory compliance.
  • Allows deterministic testing by using optional seeding for reproducible results.
  • Makes it easy for teams to integrate mock data into automated tests and examples.
What we’ll build
  • A small FastAPI service with an endpoint such as POST /api/v1/getfakedata that accepts a JSON payload describing the count and format.
  • Format options: json, csv, text (downloadable).
  • Inline code documentation and OpenAPI (automatic) documentation for discoverability.
Example JSON response
Quick reference — project deliverables Example unit test
  • This test demonstrates patching the data fetcher and verifying the endpoint response.
Implementation notes and best practices
  • Use FastAPI’s dependency injection to separate data generation from request handling; this makes testing and mocking straightforward.
  • Support a seed parameter to produce repeatable pseudo-random datasets for CI tests.
  • Keep fake data schema consistent (field names, types) so downstream systems can rely on stable shapes.
  • For large exports, stream CSV to avoid memory pressure.
Testing and documentation
  • Unit tests: use pytest + TestClient from FastAPI / Starlette; patch data generation functions to focus tests on routing and serialization.
  • Integration tests: run the real generator with a fixed seed and validate schema and sample values.
  • API docs: FastAPI exposes OpenAPI documentation at /docs and /redoc; add clear example payloads and response models.
  • CI: include tests and basic linting steps to ensure the fake-data generator remains reliable as it evolves.
Further reading and references
Using generated mock data helps maintain privacy while enabling realistic testing scenarios. Consider adding configuration options to control randomness and reproducibility (for example, using a seed).

Watch Video