-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Added comprehensive unit testing and github action to run tests on new pull requests #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
1791608
d6cb74c
5836a84
76f54f3
9c288cc
b95c05f
8b7eb48
4bb878e
e3647c4
c4dd862
48c1c46
b5c2ccf
7887050
4a8c8d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # Dockerfile for mock GitHub API service | ||
| FROM python:3.11-slim | ||
| FROM python:3.14.2-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ docker run --rm \ | |
|
|
||
| ### Container Specifications | ||
|
|
||
| - **Base Image**: `python:3.11-slim` (latest stable Python) | ||
| - **Base Image**: `python:3.14.2-slim` (latest stable Python) | ||
| - **User**: `app` (uid: 1000, gid: 1000) | ||
| - **Working Directory**: `/app` | ||
| - **Ownership**: All files in `/app` are owned by the `app` user | ||
|
|
@@ -157,6 +157,97 @@ This setup includes: | |
| - **BigQuery Emulator**: Local BigQuery instance for testing | ||
| - **ETL Service**: Configured to use both mock services | ||
|
|
||
| ### Running Tests | ||
|
|
||
| The project includes a comprehensive test suite using pytest. Tests are organized in the `test/` directory and include both unit and integration tests. | ||
dklawren marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #### Setting Up the Development Environment | ||
|
||
|
|
||
| 1. **Install Python 3.14** (or your compatible Python version) | ||
|
|
||
| 2. **Install development dependencies**: | ||
|
|
||
| ```bash | ||
| # Install the package with dev dependencies | ||
| pip install -e ".[dev]" | ||
| ``` | ||
|
|
||
| This installs: | ||
| - `pytest` - Testing framework | ||
| - `pytest-mock` - Mocking utilities for tests | ||
| - `ruff` - Linter | ||
| - `black` - Code formatter | ||
|
|
||
| 3. **Verify installation**: | ||
|
|
||
| ```bash | ||
| pytest --version | ||
| ``` | ||
|
|
||
| #### Running the Tests | ||
|
|
||
| Run all tests: | ||
|
|
||
| ```bash | ||
| pytest | ||
| ``` | ||
|
|
||
| Run tests with verbose output: | ||
|
|
||
| ```bash | ||
| pytest -v | ||
| ``` | ||
|
|
||
| Run specific test files: | ||
|
|
||
| ```bash | ||
| pytest test/test_extract_pull_requests.py | ||
| pytest test/test_transform_data.py | ||
| ``` | ||
|
|
||
dklawren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Run tests by marker: | ||
|
|
||
| ```bash | ||
| # Run only unit tests | ||
| pytest -m unit | ||
|
|
||
| # Run only integration tests | ||
| pytest -m integration | ||
|
|
||
| # Skip slow tests | ||
| pytest -m "not slow" | ||
| ``` | ||
|
|
||
| Run tests with coverage reporting: | ||
|
|
||
| ```bash | ||
| pytest --cov=. --cov-report=html | ||
| ``` | ||
|
|
||
dklawren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #### Test Organization | ||
|
||
|
|
||
| The test suite is organized into the following files: | ||
|
|
||
| - `test/conftest.py` - Shared pytest fixtures and test configuration | ||
| - `test/test_extract_pull_requests.py` - Tests for PR extraction logic | ||
| - `test/test_extract_commits.py` - Tests for commit extraction | ||
| - `test/test_extract_comments.py` - Tests for comment extraction | ||
| - `test/test_extract_reviewers.py` - Tests for reviewer extraction | ||
| - `test/test_transform_data.py` - Tests for data transformation | ||
| - `test/test_load_data.py` - Tests for BigQuery loading | ||
| - `test/test_rate_limit.py` - Tests for rate limit handling | ||
| - `test/test_main_integration.py` - End-to-end integration tests | ||
| - `test/test_logging.py` - Tests for logging setup | ||
| - `test/test_formatting.py` - Code formatting tests | ||
|
|
||
| #### Test Markers | ||
|
|
||
| Tests are marked with the following pytest markers: | ||
|
|
||
| - `@pytest.mark.unit` - Unit tests for individual functions | ||
| - `@pytest.mark.integration` - Integration tests across multiple components | ||
| - `@pytest.mark.slow` - Tests that take longer to run | ||
|
||
|
|
||
| ### Adding Dependencies | ||
|
|
||
| Add new Python packages to `requirements.txt` and rebuild the Docker image. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| Code Style Tests. | ||
| """ | ||
|
|
||
| import subprocess | ||
|
|
||
|
|
||
| def test_black(): | ||
| cmd = ("black", "--diff", "main.py") | ||
dklawren marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| output = subprocess.check_output(cmd) | ||
| assert not output, "The python code does not adhere to the project style." | ||
|
|
||
|
|
||
| def test_ruff(): | ||
dklawren marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| passed = subprocess.call(("ruff", "check", "main.py", "--target-version", "py314")) | ||
dklawren marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| assert not passed, "ruff did not run cleanly." | ||
Uh oh!
There was an error while loading. Please reload this page.