mag1024 / bosch-alarm-homeassistant

Integration for Bosch Alarm panels that use the mode2 protocol: Solution, B/G series, AMAX
22 stars 4 forks source link

Add tests #23

Closed sanjay900 closed 1 week ago

sanjay900 commented 10 months ago

One of the requirements for upstreaming is that we have tests, specifically there needs to be 100% coverage for config_flow.py but we may want to do more tests than that.

mag1024 commented 10 months ago

Don't have much experience with python tests, sorry! The only HA test I've ever had to touch is this one. Note how it uses unittest.mock to fake out the "pim" (their equivalent of the Panel). I guess we'd have to do something similar.

There's also a HA script that generates a skeleton integration, including the tests. That might be a place to start.

joostlek commented 2 months ago

Hey, so feel free to ask questions about testing. Config flow tests are quite easy, they require you to patch the library objects with mocks. Then you just programmatically enter the config flow and test the behavior of it all. Some nice integrations in core to look at are airgradient or epion.