This project demonstrates unit testing, integration testing, and test coverage reporting using pytest for a Python coupon API.
🎯 Main Goal:
Ensure robust backend logic using modern testing tools and continuous integration techniques.
| Tool | Version | Purpose |
|---|---|---|
| 🐍 Python | 3.12+ | Programming language |
| 🧪 pytest | Latest | Unit and integration tests |
| 🔄 GitHub Actions | - | CI/CD pipeline |
| 📦 pip | - | Dependency management |
devops-test-two/
├── app/
│ ├── __init__.py
│ ├── api.py
│ └── coupons.py
├── tests/
│ ├── test_api.py
│ └── test_coupons.py
├── htmlcov/ # HTML test coverage output
├── requirements.txt # Python dependencies
├── pytest.ini # pytest configuration
└── .github/workflows/ # GitHub Actions CI
| Feature | Description |
|---|---|
| ✅ Unit Tests | Covers coupon business logic |
| 🔗 Integration Tests | Ensures proper API endpoint functionality |
| 📊 Coverage Report | Generates HTML and terminal coverage report |
| 🔄 GitHub Actions | Automated test pipeline on push/PR |
git clone https://github.com/hlcxpl/devops-test-two.git
cd devops-test-twopython -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windowspip install -r requirements.txtpytestpytest --cov=app --cov-report=term-missingpytest --cov=app --cov-report=htmlOpen htmlcov/index.html in your browser.
Automated tests are triggered on push or pull requests to main branch via .github/workflows.
graph TD
A[💬 Push/PR to main] --> B[🌀 GitHub Actions]
B --> C[📦 Install dependencies]
C --> D[🧪 Run tests]
D --> E[✅ Report result]
| Test File | Type | Description |
|---|---|---|
test_api.py |
Integration | Validates endpoint functionality |
test_coupons.py |
Unit | Checks coupon logic and rules |
| Principle | Application |
|---|---|
| 🔄 Automation | End-to-end testing through GitHub Actions |
| ⚡ Fast Feedback | Instant detection of issues with every code change |
| 🛡️ Regression Safety | Logic changes are caught before reaching production |
📚 Educational purpose only.
🎓 Developed as part of DevOps testing training.
🛠️ Built with ❤️ for test-driven development and CI/CD practice.