smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
121 stars 92 forks source link

Update Mockup for Pytest for items, plugins and provide basic test case for sample Plugin #361

Open bmxp opened 3 years ago

bmxp commented 3 years ago

As SmartHomeNG grows the possibility for errors increases. We should consider to provide tests within the sample plugin thus plugin developers can write tests for their functions. Before releasing test code within sample plugin, we need to overhaul the mockup of core, plugins, items and logics. @ohinckel did an amazing job with the database tests. Unfortunately quite a number of tests did not work after core refactoring. Especially the possibility to create a plugin with a simple call does not work since the data for plugin is read within the core and not passed upon creation any more.

Example Init function of the current SamplePlugin:

def __init__(self, sh):

Old Plugins used to have an init function like:

def __init__(self, smarthome, time_ga=None, date_ga=None, send_time=False, busmonitor=False, host='127.0.0.1', port=6720, readonly=False, instance='default', enable_stats = True):
Morg42 commented 10 months ago

The "single-call" issue can be circumvented by setting the plugins self._parameters dict before the call containing all needed data.

If necessary, the original dict can be saved beforehand and restored afterwards...