Skip to content

tests: Add mock scenarios for mcp23009e driver. #200

@nedseb

Description

@nedseb

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

  1. get_iodir() / set_iodir() — read/write IODIR register
  2. get_gpio() / set_gpio() — read/write full GPIO port
  3. setup() with different configurations — input, output, with pull-up, with polarity inversion
  4. set_level() / get_level() — individual pin control
  5. get_gppu() — verify pull-up register
  6. 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

  • At least 8 new mock tests added
  • pytest tests/ -k "mock and mcp23009e" passes
  • Existing tests still pass: pytest tests/ -k mock

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions