[PR #14] Add unit test #14

Open
opened 2026-03-01 14:33:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adefossez/seewav/pull/14
Author: @nwaughachukwuma
Created: 4/20/2025
Status: 🔄 Open

Base: masterHead: add-unit-test


📝 Commits (7)

  • ee2727a Add pytest configuration and core logic tests for seewav
  • 842a2c2 Add GitHub Actions CI workflow for running unit tests
  • 2f06ec0 Enhance CI workflow to include coverage reporting and additional test dependencies
  • 7ee1b1d Add type annotations to public functions and create meta-tests for type coverage
  • 3896a50 Add support for custom output dimensions via --size CLI option
  • ec4484d Add argument-validation tests for seewav helper utilities
  • 8dd98d9 Merge pull request #1 from nwaughachukwuma/add-function-signatures

📊 Changes

8 files changed (+711 additions, -130 deletions)

View changed files

.coveragerc (+10 -0)
.github/workflows/ci.yml (+70 -0)
📝 README.md (+32 -2)
📝 seewav.py (+237 -128)
tests/conftest.py (+76 -0)
tests/test_arguments.py (+132 -0)
tests/test_basic.py (+106 -0)
tests/test_signatures.py (+48 -0)

📄 Description

Summary

This PR modernizes seewav by adding continuous-integration, full type-hints, stricter unit-testing and a clearer, more ergonomic CLI/API.


Key Features & Improvements

  1. GitHub Actions CI

    • Runs the test-suite on Python 3.9 → 3.12
    • Includes pytest-cov; uploads an XML coverage artefact
  2. 100% Type-annotated Public API

    • All public helpers in seewav.py now have explicit PEP-484 annotations
    • New meta-test (tests/test_signatures.py) fails the build if a public function lacks annotations
  3. Unified Size Handling

    • New --size WxH CLI flag (e.g. --size 640x360)
    • Existing -W/--width and -H/--height remain with defaults (480 × 300); --size overrides them
    • Library call continues to accept the size=(w, h) tuple
  4. Robust Argument Validation

    • Added seewav.parse_size_token helper
    • Expanded test-suite (tests/test_arguments.py) checks:
      • parse_size_token – valid & invalid paths
      • parse_color – valid & invalid RGB strings
      • read_audio – fails gracefully on non-audio files
      • visualize – detects channel/--stereo mismatches
    • Test count increased from 9 → 27; all green
  5. Documentation Updates

    • README gains a "Library usage & type-safety" section and updated option table:
      --size WxH            Output video dimension (e.g. 640x360)
      -W, --width WIDTH     Width in pixels (default 480)
      -H, --height HEIGHT   Height in pixels (default 300)
      
    • Example snippet for programmatic use with size=(640, 360)

🛠️ Implementation Notes

  • CI Workflow.github/workflows/ci.yml
    • Installs minimal deps (numpy, tqdm, pytest, pytest-cov) and optional ffmpeg
  • Helper Functions
    • parse_size_token(token: str) -> tuple[int, int]
    • Improved error messages via fatal()
  • Backward Compatibility
    • Width/height flags preserved; no breaking change for existing users
  • Coverage
    • .coveragerc excludes tests/venv; --cov-report=term-missing --cov-report=xml in CI

🔍 How to Review

  1. API surface – inspect new/changed functions & type-hints in seewav.py
  2. CLI behaviour – run:

seewav --size 800x450 in.wav out.mp4
seewav -W 800 -H 450 in.wav out.mp4 # still works

  1. Tests – execute pytest -vv locally; 27 tests including argument-validation and meta type-checking should pass
  2. CI – confirm new workflow passes on all Pythons

This PR brings the project up to date with modern Python best-practices, increases test coverage, and lays the groundwork for future features with confidence in correctness.

Co-author: OpenAI o3 model via Codex CLI


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adefossez/seewav/pull/14 **Author:** [@nwaughachukwuma](https://github.com/nwaughachukwuma) **Created:** 4/20/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `add-unit-test` --- ### 📝 Commits (7) - [`ee2727a`](https://github.com/adefossez/seewav/commit/ee2727a069023cd59b7ff9391dff71ec60f240e0) Add pytest configuration and core logic tests for seewav - [`842a2c2`](https://github.com/adefossez/seewav/commit/842a2c264197a3cf8788cca3a8b6a0e24c1b1bf5) Add GitHub Actions CI workflow for running unit tests - [`2f06ec0`](https://github.com/adefossez/seewav/commit/2f06ec0a319f83f11315369c46da977df604f20e) Enhance CI workflow to include coverage reporting and additional test dependencies - [`7ee1b1d`](https://github.com/adefossez/seewav/commit/7ee1b1d16f80b64d45eb3512e27da60946490140) Add type annotations to public functions and create meta-tests for type coverage - [`3896a50`](https://github.com/adefossez/seewav/commit/3896a50a36a15db78d4654680d3f135fec0eae48) Add support for custom output dimensions via --size CLI option - [`ec4484d`](https://github.com/adefossez/seewav/commit/ec4484d31d9341fddcdae176e1effb9b75e72d71) Add argument-validation tests for seewav helper utilities - [`8dd98d9`](https://github.com/adefossez/seewav/commit/8dd98d98e3adf93408d4578aa060d4d1d7b044ac) Merge pull request #1 from nwaughachukwuma/add-function-signatures ### 📊 Changes **8 files changed** (+711 additions, -130 deletions) <details> <summary>View changed files</summary> ➕ `.coveragerc` (+10 -0) ➕ `.github/workflows/ci.yml` (+70 -0) 📝 `README.md` (+32 -2) 📝 `seewav.py` (+237 -128) ➕ `tests/conftest.py` (+76 -0) ➕ `tests/test_arguments.py` (+132 -0) ➕ `tests/test_basic.py` (+106 -0) ➕ `tests/test_signatures.py` (+48 -0) </details> ### 📄 Description ### Summary This PR modernizes `seewav` by adding continuous-integration, full type-hints, stricter unit-testing and a clearer, more ergonomic CLI/API. --- ### ✨ Key Features & Improvements 1. **GitHub Actions CI** - Runs the test-suite on Python 3.9 → 3.12 - Includes `pytest-cov`; uploads an XML coverage artefact 2. **100% Type-annotated Public API** - All public helpers in `seewav.py` now have explicit PEP-484 annotations - New meta-test (`tests/test_signatures.py`) fails the build if a public function lacks annotations 3. **Unified Size Handling** - New `--size WxH` CLI flag (e.g. `--size 640x360`) - Existing `-W/--width` and `-H/--height` remain with defaults (480 × 300); `--size` overrides them - Library call continues to accept the `size=(w, h)` tuple 4. **Robust Argument Validation** - Added `seewav.parse_size_token` helper - Expanded test-suite (`tests/test_arguments.py`) checks: - `parse_size_token` – valid & invalid paths - `parse_color` – valid & invalid RGB strings - `read_audio` – fails gracefully on non-audio files - `visualize` – detects channel/`--stereo` mismatches - Test count increased from 9 → 27; all green 5. **Documentation Updates** - README gains a "Library usage & type-safety" section and updated option table: ``` --size WxH Output video dimension (e.g. 640x360) -W, --width WIDTH Width in pixels (default 480) -H, --height HEIGHT Height in pixels (default 300) ``` - Example snippet for programmatic use with `size=(640, 360)` --- ### 🛠️ Implementation Notes - **CI Workflow** — `.github/workflows/ci.yml` - Installs minimal deps (`numpy`, `tqdm`, `pytest`, `pytest-cov`) and optional `ffmpeg` - **Helper Functions** - `parse_size_token(token: str) -> tuple[int, int]` - Improved error messages via `fatal()` - **Backward Compatibility** - Width/height flags preserved; no breaking change for existing users - **Coverage** - `.coveragerc` excludes tests/venv; `--cov-report=term-missing --cov-report=xml` in CI --- ### 🔍 How to Review 1. **API surface** – inspect new/changed functions & type-hints in `seewav.py` 2. **CLI behaviour** – run: > seewav --size 800x450 in.wav out.mp4 > seewav -W 800 -H 450 in.wav out.mp4 # still works 3. **Tests** – execute `pytest -vv` locally; 27 tests including argument-validation and meta type-checking should pass 4. **CI** – confirm new workflow passes on all Pythons --- This PR brings the project up to date with modern Python best-practices, increases test coverage, and lays the groundwork for future features with confidence in correctness. Co-author: OpenAI o3 model via Codex CLI --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/seewav#14
No description provided.