Merge branch 'current' into next
This commit is contained in:
commit
04b4f58407
31 changed files with 284 additions and 45 deletions
|
@ -27,9 +27,19 @@ $ tox
|
|||
|
||||
This will run unit tests against python 3.4 and 3.5 (if both are available locally), as well as run a set of tests which validate `pep8` and `pylint` style of the code.
|
||||
|
||||
You can optionally run tests on only one tox target using the `-e` option to select an environment.
|
||||
#### {% linkable_title Testing Tips %}
|
||||
|
||||
For instance `tox -e lint` will run the linters only, `tox -e py34` will run unit tests only on python 3.4.
|
||||
You can optionally run tests on only one tox target using the `-e` option to select an environment. For instance `tox -e lint` will run the linters only, `tox -e py34` will run unit tests only on python 3.4.
|
||||
|
||||
Tox uses virtual environments under the hood to create isolated testing environments. The Tox virtual environments will get out date when requirements change causing test errors. Run `tox -r` to create new Tox virtual environments.
|
||||
|
||||
During development on a specific file, it can speed up your workflow to just run tests and linting related to the file that you're working on. To run individual files:
|
||||
|
||||
```bash
|
||||
$ flake8 homeassistant/core.py
|
||||
$ pylint homeassistant/core.py
|
||||
$ py.test tests/test_core.py
|
||||
```
|
||||
|
||||
### {% linkable_title Prevent Linter Errors %}
|
||||
|
||||
|
@ -37,7 +47,7 @@ You can save yourself the hassle of extra commits just to fix style errors by en
|
|||
|
||||
```bash
|
||||
$ pip3 install flake8 flake8-docstrings
|
||||
$ flake8 --install-hook
|
||||
$ flake8 --install-hook=git
|
||||
```
|
||||
|
||||
The flake8-docstrings extension will check docstrings according to [PEP257](https://www.python.org/dev/peps/pep-0257/) when running flake8.
|
||||
|
|
|
@ -9,7 +9,9 @@ sharing: true
|
|||
footer: true
|
||||
---
|
||||
|
||||
The `configuration.yaml` file contains the configuration options for components and platforms. To ensure that the given configuration provided by the user is valid we use [voluptuous](https://pypi.python.org/pypi/voluptuous) to check it. Certain entries are optional or could be required for the setup of a platform or a component. Others must be of a certain type or out of an already defined list. This will ensure that the users are notified if something is wrong with a platform or component setup before Home Assistant is running.
|
||||
The `configuration.yaml` file contains the configuration options for components and platforms. To ensure that the given configuration provided by the user is valid we use [voluptuous](https://pypi.python.org/pypi/voluptuous) to check it. Certain entries are optional or could be required for the setup of a platform or a component. Others must be of a definied type or out of an already defined list.
|
||||
|
||||
The goal of testing the configuration is to assure that users have a great experience due to notifications if something is wrong with a platform or component setup before Home Assistant is running.
|
||||
|
||||
Beside the [voluptuous](https://pypi.python.org/pypi/voluptuous) default types are a bunch of custom types available. To get a full overview take a look at the [config_validation.py](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/helpers/config_validation.py) helper.
|
||||
|
||||
|
@ -57,18 +59,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
|
||||
### {% linkable_title Port %}
|
||||
|
||||
As all port numbers are coming out of the range 1 till 65535 a range check should be performed.
|
||||
As all port numbers are coming out of the range 1 till 65535.
|
||||
|
||||
```python
|
||||
DEFAULT_PORT = 993
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
...
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT):
|
||||
vol.All(vol.Coerce(int), vol.Range(min=1, max=65535)),
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
```
|
||||
|
||||
### {% linkable_title Sensor types %}
|
||||
### {% linkable_title Lists %}
|
||||
|
||||
If a sensor has a pre-defined list of available options it should be tested if the configuration entry matches it.
|
||||
|
||||
|
@ -81,7 +82,7 @@ SENSOR_TYPES = {
|
|||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
...
|
||||
vol.Optional(CONF_MONITORED_VARIABLES, default=[]):
|
||||
[vol.In(SENSOR_TYPES)],
|
||||
vol.All(ensure_list, [vol.In(SENSOR_TYPES)]),
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -14,5 +14,6 @@ There are a bunch of online services which can help you if you are developing fo
|
|||
- [Coveralls](https://coveralls.io/github/home-assistant/home-assistant)
|
||||
- [Travis CI](https://travis-ci.org/home-assistant/home-assistant)
|
||||
- [gemnasium](https://gemnasium.com/github.com/home-assistant/home-assistant)
|
||||
- [Requires.io](https://requires.io/github/home-assistant/home-assistant/requirements/?branch=dev)
|
||||
- [Pivotal Tracker](https://www.pivotaltracker.com/n/projects/1250084)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue