Skip to content

apds9960: Add test scenario for gesture and color sensor.#48

Merged
nedseb merged 4 commits intomainfrom
tests/apds9960-scenario
Mar 12, 2026
Merged

apds9960: Add test scenario for gesture and color sensor.#48
nedseb merged 4 commits intomainfrom
tests/apds9960-scenario

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 12, 2026

Closes #29

Summary

  • Add YAML test scenario for APDS-9960 gesture/color/proximity sensor
  • Uses uAPDS9960 class (MicroPython I2C API variant)
  • Add hardware_init to enable light and proximity sensors before reading
  • Split device ID test: _read_byte_data for mock, read_register for hardware

Test commands

# Mock tests (CPython)
python3 -m pytest tests/ -v --driver apds9960

# Hardware tests (STeaMi board)
python3 -m pytest tests/ -v --port /dev/ttyACM0 --driver apds9960 -s

Test results

============================== test session starts ==============================
platform linux -- Python 3.13.7, pytest-8.3.5, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/nedjar/sandbox/micropython-steami-lib
configfile: pytest.ini
plugins: typeguard-4.4.2
collected 58 items                                                                                                                                                                                                                                                          

tests/test_scenarios.py::test_scenario[apds9960/Verify device ID register (mock)/mock] 0xAB
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Verify device ID register (hardware)/hardware] 0xAB
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Read ambient light returns expected value/mock] 0x0100
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Read proximity returns expected value/mock] 0x50
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Read red light returns expected value/mock] 0x80
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Ambient light in plausible range/hardware] 812
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Proximity in plausible range/hardware] 18
PASSED
tests/test_scenarios.py::test_scenario[apds9960/Light and proximity values feel correct/hardware]   Ambient light: 810 
  Proximity: 20 
  [MANUAL] Les valeurs de lumière ambiante et de proximité sont-elles cohérentes ? [y/n] y
True
PASSED

============================== 8 passed in 35.38s ===============================

@nedseb nedseb requested review from Charly-sketch and Copilot March 12, 2026 12:58
@nedseb nedseb self-assigned this Mar 12, 2026
@nedseb nedseb added enhancement New feature or request test labels Mar 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new YAML scenario to exercise the apds9960 driver via the shared scenario-based test framework, covering mock ID/value reads and basic hardware sanity checks.

Changes:

  • Introduces tests/scenarios/apds9960.yaml defining mock register fixtures for APDS-9960.
  • Adds mock-mode assertions for ID / ambient light / proximity / red channel reads.
  • Adds hardware-mode “plausible range” checks and a manual validation step for ambient light + proximity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/scenarios/apds9960.yaml Outdated
@nedseb nedseb merged commit d3f6d9f into main Mar 12, 2026
5 checks passed
@nedseb nedseb deleted the tests/apds9960-scenario branch March 12, 2026 13:17
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: Add test scenario for APDS-9960 gesture and color sensor.

2 participants