sde1000 / python-dali

Library for controlling DALI lighting systems
Other
150 stars 71 forks source link

Add "level" support to fakes.py #101

Closed sl-wallace closed 2 years ago

sl-wallace commented 2 years ago

This feature branch adds the necessary message handling to fakes.py to handle the various DALI level control messages, e.g. DAPC, RecallMaxLevel, etc. Such a feature was found to be helpful when testing out higher level code which uses this library, by enabling the use of fake DALI devices which correctly respond to certain messages.

Perhaps this isn’t the ideal place for such code to live, but since fakes.py already implemented the majority of the necessary features this seems to be the best fit within the existing structure.

Tests have been added to cover all of the additional code.

sde1000 commented 2 years ago

(Will have a closer look in about a week and a half - I'm running the bar at https://emfcamp.org/ this week and it's taking all my time!)

sde1000 commented 2 years ago

Looks good to me, and will be useful to include.

The only thing blocking me merging it is the use of bare assert in the tests — you should be using the various assertSomething methods of unittest.TestCase instead, eg. self.assertEqual(resp.value, 0) instead of assert resp.value == 0. See the unittest documentation for details.

sl-wallace commented 2 years ago

Thanks for that @sde1000 , I'll update my tests and push some more changes in the next day or two :smile:

sl-wallace commented 2 years ago

Hi @sde1000, I've updated the test code to use assertEqual rather than bare assert statements :smile:

sde1000 commented 2 years ago

Thank you!