-
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 all commits
1791608
d6cb74c
5836a84
76f54f3
9c288cc
b95c05f
8b7eb48
4bb878e
e3647c4
c4dd862
48c1c46
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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #### Setting Up the Development Environment | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile should do all of this for us. We should update these docs to demonstrate how to set up the environment and run the tests using Docker. |
||||||
|
|
||||||
| 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 tests/test_extract_pull_requests.py | ||||||
| pytest tests/test_transform_data.py | ||||||
| ``` | ||||||
|
|
||||||
|
Comment on lines
160
to
207
|
||||||
| 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 | ||||||
| ``` | ||||||
|
|
||||||
| #### Test Organization | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need a walkthrough of the test files, let's remove this section. The entire file needs to be trimmed down to just the essentials, it is too verbose for what it is communicating. |
||||||
|
|
||||||
| The test suite is organized into the following files: | ||||||
|
|
||||||
| - `tests/conftest.py` - Shared pytest fixtures and test configuration | ||||||
| - `tests/test_extract_pull_requests.py` - Tests for PR extraction logic | ||||||
| - `tests/test_extract_commits.py` - Tests for commit extraction | ||||||
| - `tests/test_extract_comments.py` - Tests for comment extraction | ||||||
| - `tests/test_extract_reviewers.py` - Tests for reviewer extraction | ||||||
| - `tests/test_transform_data.py` - Tests for data transformation | ||||||
| - `tests/test_load_data.py` - Tests for BigQuery loading | ||||||
| - `tests/test_rate_limit.py` - Tests for rate limit handling | ||||||
| - `tests/test_main_integration.py` - End-to-end integration tests | ||||||
| - `tests/test_logging.py` - Tests for logging setup | ||||||
| - `tests/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 | ||||||
|
Comment on lines
+247
to
+249
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These either don't exist, or we don't use them. |
||||||
|
|
||||||
| ### Adding Dependencies | ||||||
|
|
||||||
| Add new Python packages to `requirements.txt` and rebuild the Docker image. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # | ||
| # This file is autogenerated by pip-compile with Python 3.14 | ||
| # This file is autogenerated by pip-compile with Python 3.10 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile indicates we're using Python 3.14, but these requirements were generated with Python 3.10. We'll probably need to re-generate requirements. |
||
| # by the following command: | ||
| # | ||
| # pip-compile --generate-hashes pyproject.toml | ||
|
|
||
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test