-
Notifications
You must be signed in to change notification settings - Fork 36
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
Include, use and check example data in unittests #85
Conversation
joro75
commented
Oct 12, 2021
- Add the possibility to provide a modified Controller
- Add an offline Controller that is using example data loaded from JSON files in the tests/data/ directory
- Add unittest that performs an offline login() and get_uuid()
- Add unittest that retrieve the available vehicles
- Add unittest that retrieves the vehicle status
- Example data is anonymized
Will look at it tomorrow!😴 Will this make it possible to run tests against different car models? I have an Aygo and it does not report a lot of things. But recently a guy with a Toyota Mirai Hydrogen car asked for support in the Home Assistant integration and it would be awesome if we can test against many different models. Or am i missing something? 🤔 |
These improvements will indeed make it possible to use 'offline' data from (other) cars. This is currently used for performing the unittests, without having any connection to the Toyota servers. Be aware that I did not create any code yet to create the .json files that are needed for the data. I now created those by some hacking in the code and manually calling it from the Python interpreter. It however should not be too difficult to create some code that retrieves the online data and stores them as an example offline data. The contents of the .json files is the actual data that is received from the toyota server endpoint, it thus is the 'raw' data and I already saw that it contains data elements for which no mapping is present yet in With some modifications in the example data we can also create a vehicle that has all the doors and windows open, and that has the lights on. That example data can then be used to create unittests to check if |
I actually didn't mean doing it in the Ha Integration, but rather build on what you are doing now and just use another set of JSON files. Actually it does not have to be from different car models, but rather just to make sure that module creates the right objects and attributes when given a specific combination of "offline" data. One of the problems is that Toyota is not consistent in what they return from the different API's. Like HVAC data, there are two different endpoints for this( possible more) depending on model. It would be awesome to test against both types. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments 😃 Other then that, this looks good to me. 🚀
"failedUnlockPreconditions": ["alarmLocked"] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you are aware of this. This endpoint can also contain energy information (range, fuel level) and HVAC information for some cars. See example below:
{
"energy":[
{
"timestamp":"2021-09-19T14:02:37Z",
"type":"HYDROGEN",
"level":58.8,
"remainingRange":295
}
],
"climate": {
"Climate dict containing information about the HVAC system."
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am aware of that depending on the actual vehicle that is used, different information can be provided. I also suspect that this will be the biggest challenge for the mytoyota
library, as the retrieved data will be different dependning on the model of the Toyota, and the options that are present.
The information that I included in these JSON files is based on the information that is received from my Toyota. And because it isn't a hybrid one, it doesn't contain some of the informations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should find a way to test against most of them. I have a collection of different data from each car in the HA integrations GitHub. But I can do that as i have a good knowledge of which car returns what. 😃