HelloThisIsFlo / Appdaemon-Test-Framework

Clean, human-readable tests for Appdaemon
https://hellothisisflo.github.io/Appdaemon-Test-Framework/
MIT License
45 stars 19 forks source link

Add name attribue to mock hass object #16

Closed lifeisafractal closed 5 years ago

lifeisafractal commented 5 years ago

Some of my automatons make use of the Hass.name attribute, but this doesn't exist in the test framework as the Hass.__init__() function mocked without any behavior. This PR adds a new mock that will set the name attribute.

I'm not super familiar with mocking in Python, so the spec'd solution I came to was more pragmatic than anything else. I'm very open to discussing other ways of accomplishing this, any maybe learning something new :).

HelloThisIsFlo commented 5 years ago

Thanks for the PR. Before merging I'd like to get it locally and spend some time to be sure I understand what's happening. However, this week is tight, so this PR might hang a little while. I won't forget about it, for sure ;)

lifeisafractal commented 5 years ago

No problem about the time, I know how it is :). I've got another larger branch I'm working on now. I'm going to open an issue for that so we can have some design discussion before I bring it to completion.

HelloThisIsFlo commented 5 years ago

Oh and one more last thing. Could you fix the conflicts in init_framework.py ? It's a simple fix: I merged your first change with the extra functions, you just need to update the revamped mocking mechanism with the extra functions you added in the other PR ;)

lifeisafractal commented 5 years ago

I merged in upstream master and resolved the conflicts. This should be good to go.

One note, the work I'm doing for issue #18 will overhaul some of this further, but I think it's still worth while to get this incremental improvement in.

HelloThisIsFlo commented 5 years ago

Thanks a lot! I'm merging 🙂

And I finally have some time to take a look at The big one 😁 Will do so now 😉