Description
The mcp23009e driver has only 5 mock tests, which is low compared to other drivers (hts221: 18, ism330dl: 34, lis2mdl: 15). Add mock tests to improve coverage.
What to do
Add tests to tests/scenarios/mcp23009e.yaml in the mock section.
Methods to test
get_iodir() / set_iodir() — read/write IODIR register
get_gpio() / set_gpio() — read/write full GPIO port
setup() with different configurations — input, output, with pull-up, with polarity inversion
set_level() / get_level() — individual pin control
get_gppu() — verify pull-up register
power_off() / power_on() — verify reset pin toggling
Example test
- name: "Set IODIR register"
action: script
script: |
dev.set_iodir(0xF0)
result = dev.get_iodir() == 0xF0
expect_true: true
mode: [mock]
Reference
- Driver code:
lib/mcp23009e/mcp23009e/device.py
- Existing tests:
tests/scenarios/mcp23009e.yaml
- Note: the mock needs a
FakePin for reset_pin — check how the existing tests handle it
Checklist
Description
The
mcp23009edriver has only 5 mock tests, which is low compared to other drivers (hts221: 18, ism330dl: 34, lis2mdl: 15). Add mock tests to improve coverage.What to do
Add tests to
tests/scenarios/mcp23009e.yamlin the mock section.Methods to test
get_iodir()/set_iodir()— read/write IODIR registerget_gpio()/set_gpio()— read/write full GPIO portsetup()with different configurations — input, output, with pull-up, with polarity inversionset_level()/get_level()— individual pin controlget_gppu()— verify pull-up registerpower_off()/power_on()— verify reset pin togglingExample test
Reference
lib/mcp23009e/mcp23009e/device.pytests/scenarios/mcp23009e.yamlFakePinforreset_pin— check how the existing tests handle itChecklist
pytest tests/ -k "mock and mcp23009e"passespytest tests/ -k mock