Skip to content

Conversation

@xlfe
Copy link
Owner

@xlfe xlfe commented May 31, 2025

No description provided.

This commit introduces the first batch of unit tests for both the Python and Clojure parts of the Radiale project, based on the previously defined testing strategy.

**Python Changes:**
- Added `tests` directory with structure mirroring `radiale` package.
- Created `requirements-dev.txt` with `pytest`, `pytest-cov`, and `pytest-asyncio`.
- Updated `.gitignore` for Python test artifacts.
- Implemented unit tests for:
    - `radiale/schedule.py`: Testing time and solar event calculations.
    - `radiale/pod.py`: Testing core pod logic, message queuing (`OutgoingQ`), and invocation of basic operations.
    - `radiale/mdns.py`: Testing mDNS service discovery logic with zeroconf mocking.
    - `radiale/mqtt.py`: Testing MQTT listener logic.
    - `radiale/chromecast.py`: Testing Chromecast interaction logic.

**Clojure Changes:**
- Added `test` directory with structure mirroring `src/radiale`.
- Updated `deps.edn` with a `:test` alias to discover and run tests.
- Implemented unit tests for:
    - `radiale/schedule.clj`: Testing Clojure-side scheduling logic.
    - `radiale/state.clj`: Testing state unpacking and watcher functionality.
    - `radiale/watch.clj`: Testing custom watch registration and message matching.
    - `radiale/core.clj`: Testing core message dispatch (`try-fn`), state updates (`update-or-add`), and event loop processing.

These tests establish a foundation for improving code quality and reliability. Further tests for remaining modules and interaction layers are planned.
… done so far and provide feedback for Jules to continue.
This commit introduces an extensive suite of unit tests for both the Python and Clojure components of the Radiale project. It also establishes a GitHub Actions CI workflow to automate test execution.

**Key Changes:**

1.  **Python Unit Tests:**
    - Test environment set up with pytest, pytest-cov, and pytest-asyncio.
    - Unit tests implemented for:
        - `radiale/schedule.py`
        - `radiale/pod.py` (core logic, OutgoingQ, RadialePod invocation)
        - `radiale/mdns.py`
        - `radiale/mqtt.py`
        - `radiale/chromecast.py`
        - `radiale/deconz.py`
        - `radiale/esphome.py`
    - Extensive use of mocking for external libraries and internal components.

2.  **Clojure Unit Tests:**
    - Test environment configured in `deps.edn` with a `:test` alias.
    - Unit tests implemented for:
        - `radiale/schedule.clj`
        - `radiale/state.clj`
        - `radiale/watch.clj`
        - `radiale/core.clj` (try-fn dispatch, state management, run loop)
        - `radiale/deconz.clj`
        - `radiale/esp.clj`
        - `radiale/chromecast.clj`
    - Utilizes `with-redefs` for mocking and `clojure.core.async` for async testing.

3.  **Interaction Tests (Simplified):**
    - Added `test/radiale/interaction_test.clj` to verify Clojure's marshalling of arguments to `babashka.pods/invoke` and handling of simulated success callbacks.

4.  **CI and Test Execution:**
    - Created `.github/workflows/ci.yml` for GitHub Actions to run Python and Clojure tests on push/pull_request.
    - Added `run-tests.sh` for local consolidated test execution.
    - Updated `.gitignore` and `requirements-dev.txt`.

This comprehensive testing setup significantly improves the project's robustness and maintainability by providing automated checks for code correctness.
… CI.

I changed the GitHub Actions workflow to use 'clojure -M:test' instead of 'clojure -X:test' for running the Clojure tests.

The :test alias in your deps.edn is defined using :main-opts, which are intended for use with -M (or older -A/clj). Using -X:test without a corresponding :exec-fn or command-line function was causing the error "No function found on command line or in :exec-fn".

This change ensures your Clojure tests are executed correctly in the CI environment as per the deps.edn configuration.
@xlfe xlfe merged commit d8b31ad into main May 31, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants