home-assistant / architecture

Repo to discuss Home Assistant architecture
315 stars 99 forks source link

Question about CONF in unit_tests #432

Closed ziv1234 closed 4 years ago

ziv1234 commented 4 years ago

Context

I hope that this is the right forum. In many unit-tests, we need to use some CONF params. My question is whether it is best to use the imported CONF_XX parameter, or just use the string (e.g. use "host" instead of CONF_HOST). The advantage (and the disadvantage) of the CONF is that if the value of that CONF ever changes, it won't break the unit tests. However, this means that if someone accidentally changes them, it will go unnoticed by the unit tests

Proposal

Not really a proposal, but more of a HA coding style question, but if a proposal is needed, I believe that explicit (e.g. "host") is better as changing CONF values is a breaking change, and should be at a minimum known what it breaks. Wanted to know before refactoring my unit-tests

Consequences

What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.

frenck commented 4 years ago

The general rule of thumb: Please use constants as much as possible.

If you have questions in general, please use the community forum or, even better, join or Discord server. We have development channels over there.

👍