Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Z-Wave #6437

Closed
15 tasks done
balloob opened this issue Mar 5, 2017 · 6 comments
Closed
15 tasks done

Add tests for Z-Wave #6437

balloob opened this issue Mar 5, 2017 · 6 comments

Comments

@balloob
Copy link
Member

balloob commented Mar 5, 2017

If we want to consider Z-Wave a serious member of the Home Assistant family, we will need to make sure there is proper test coverage of the component and platforms.

@andrey-git made a very small start but we need more tests, a lot more. We should create a mock OpenZWave like we did for MQTT, so that it will be easy to do something like mock_zwave.trigger_value_changed(…) (Update Mar '17: the mock Open Z-Wave stack has been added)

Here is a quick (and not complete) roundup of things that will require tests:

  • Config is passed to ZWaveOption in setup
  • Test for each service
  • Auto heal is set up correctly and calls right commands
  • Z-Wave cover
  • Z-Wave switch
  • Z-Wave sensor
  • Z-Wave light
  • Z-Wave climate
  • Z-Wave lock
  • Z-Wave binary_sensor
  • Test workaround WORKAROUND_NO_OFF_EVENT
  • Test workaround WORKAROUND_NO_POSITION
  • Test workaround WORKAROUND_REVERSE_OPEN_CLOSE
  • Test workaround WORKAROUND_REFRESH_NODE_ON_UPDATE
  • Test workaround WORKAROUND_IGNORE

To ensure we are not making it worse, all Z-Wave PRs moving forward will require tests to be written.

As of April 6, 2017: 71.46% coverage for main file: report. All other files have 100% 🎉

@emlove
Copy link
Contributor

emlove commented Mar 7, 2017

I think as the first core what we'll need is a mock ZWaveNetwork that returns mock node and value objects. I think it has to be mocked at a layer a little bit higher than mqtt, since we don't even build openzwave on CI.

@andrey-git
Copy link
Contributor

I'll try to write some basic mocks today.

Looking forward we might want to put it in an external library, but let's start small :)

@emlove
Copy link
Contributor

emlove commented Mar 7, 2017

We should be able to create a separate file in the tests folder that can hold all the mock classes, and then import that where we need it. We can throw some module patching logic like you have here at the beginning of this new file.

I'll hold off on this for now if you're going to work on it. We can probably divvy it up once we get a solid template.

@andrey-git
Copy link
Contributor

Eventually won't have time for this today. Hopefully tomorrow.

@balloob
Copy link
Member Author

balloob commented Mar 8, 2017

I'm giving it a spin to see what I can come up with.

@balloob
Copy link
Member Author

balloob commented Mar 8, 2017

No, I did not cook this up in the 6 minutes since my last comment ;-) I only realized that I forgot to post that I was looking into it.

Anyway, I have a first pass up for the Z-Wave light platform: #6483

Includes a MockNode, MockValue and firing value_changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants