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

[fix] get_state to match appdaemon's api #13

Closed jshridha closed 5 years ago

jshridha commented 5 years ago

There is currently a bug in the testing framework that causes attributes to be returned when they should throw a TypeError. Appdaemon's api only takes one positional argument and then catches all kwargs. The framework takes two positional arguments leading to a mismatch in APIs.

For example, this would throw a TypeError in appdaemon, but does not in the framework:

self.get_state(self.entity_id, "friendly_name")

This should actually be called as:

self.get_state(self.entity_id, attribute="friendly_name")
HelloThisIsFlo commented 5 years ago

Good catch, thanks a lot for the PR!

I added a test and slightly refactored the implementation. I pushed on this PR so you're still credited for the fix 🙂

Merging now