fix action Action commit Created package file minor updates Add binary_sensor Updated package file Updated package file Fix BinarySensor Class name Add more descriptions Updated package file Move stuff Updated package file add binary_sensor to resources.json Updated package file Add configuration Updated package file Remove switch Adds CONTRIBUTING Fix broken link Remove refrences Fix links fix broken actions Update actions Updated package file Updated package file Black format Fix config issues Updated package file Fix icon for binary_sensor Add switch platform Update README.md (#1) * Update README.md * Update README.md Update CONTRIBUTING.md (#2) Update __init__.py (#3) * Update __init__.py * Set enabled default to `True` Update const.py (#4) cleanup badges/add style (#5) * shield that supports styling * badge cleanup * Change discord ID Correct typo Create manifest.json (#12) Fixes https://github.com/custom-components/blueprint/issues/10 Move manifest to correct dir Fixes #9 by renaming the file Updates, updates, more updates, worst commit messge ever! revert Update main.workflow Delete resources.json Create example.yaml Update README.md Summer update 😎 Adds info about devcontainer Adds pylint Add translation example remove stalebot Adds integrationhelper adds requirements.txt Adds "tabnine.tabnine-vscode" to devcontainer Add support for config_flow configuration Add config_flow "docs" Update README.md use https for pip install ha@dev (#15) Typo on README.md (#18) Fix various typos in comments (#19) Add hassfest action (#22) * Add hassfest action * Fix manifest issue Spring cleaning ☀️ (#23) * Spring cleaning * Actions * Fix branches * Changes for config_flow Show how to only allow one instance Adds HACS validation action (#24) Update postCreateCommand Update tasks Minor updates (#26) * link correction in README.md and info.md * Add READMME.md for .devcontainer * Add automation.yaml file in the configuration * Complete CONTRIBUTING.md Improve README for container dev and library update. (#27) Feature/setup cfg (#28) * Add setup.cfg * Run black and isort. * Add blueprint to first party. * Make const import consistent. Move translation files Fixes #32 Use CoordinatorEntity (#33) Co-authored-by: Joakim Sørensen <hi@ludeeus.dev> Fixed typos (#34) Fix directory name for translations and link to the documentation (#36) Fix info.md (#40) Use debian based devcontainer (#44) Remove sampleclient (#45) Rename [blueprint|Blueprint] -> [integration_blueprint|Integration blueprint] (#47) Change HACS action (#39) Fix wrong path for link (#48) For an unknown reason the link was pointing to a one of my repository. Probably a too quick copy/paste. Add french translation and strings improvements (#49) Reusing work done on strings.json done in #37 Add example tests (#50) Prepare and explain how to step by step debugging (#51) Add version Fix testing by bumping pytest-homeassistant-custom-component (#54) Fix typo in api.py (#55) passeword -> password Fix a typo in the readme (#56) Update .gitignore to include .idea (#57) Update .gitignore to include .idea for those using Py Charm Add iot_class to manifest Use `enable_custom_integrations` fixture by default (#58) Fix typo (#59) retain user input after an error (#52) Update README.md Closes #61 remove async_timeout.timeout loop arg (#65) Correct name "Blueprint" ->"Integration blueprint" (#64) change entity.py to use extra_state_attributes (#66)
64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
"""Global fixtures for integration_blueprint integration."""
|
|
# Fixtures allow you to replace functions with a Mock object. You can perform
|
|
# many options via the Mock to reflect a particular behavior from the original
|
|
# function that you want to see without going through the function's actual logic.
|
|
# Fixtures can either be passed into tests as parameters, or if autouse=True, they
|
|
# will automatically be used across all tests.
|
|
#
|
|
# Fixtures that are defined in conftest.py are available across all tests. You can also
|
|
# define fixtures within a particular test file to scope them locally.
|
|
#
|
|
# pytest_homeassistant_custom_component provides some fixtures that are provided by
|
|
# Home Assistant core. You can find those fixture definitions here:
|
|
# https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/blob/master/pytest_homeassistant_custom_component/common.py
|
|
#
|
|
# See here for more info: https://docs.pytest.org/en/latest/fixture.html (note that
|
|
# pytest includes fixtures OOB which you can use as defined on this page)
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
pytest_plugins = "pytest_homeassistant_custom_component"
|
|
|
|
|
|
# This fixture enables loading custom integrations in all tests.
|
|
# Remove to enable selective use of this fixture
|
|
@pytest.fixture(autouse=True)
|
|
def auto_enable_custom_integrations(enable_custom_integrations):
|
|
yield
|
|
|
|
|
|
# This fixture is used to prevent HomeAssistant from attempting to create and dismiss persistent
|
|
# notifications. These calls would fail without this fixture since the persistent_notification
|
|
# integration is never loaded during a test.
|
|
@pytest.fixture(name="skip_notifications", autouse=True)
|
|
def skip_notifications_fixture():
|
|
"""Skip notification calls."""
|
|
with patch("homeassistant.components.persistent_notification.async_create"), patch(
|
|
"homeassistant.components.persistent_notification.async_dismiss"
|
|
):
|
|
yield
|
|
|
|
|
|
# This fixture, when used, will result in calls to async_get_data to return None. To have the call
|
|
# return a value, we would add the `return_value=<VALUE_TO_RETURN>` parameter to the patch call.
|
|
@pytest.fixture(name="bypass_get_data")
|
|
def bypass_get_data_fixture():
|
|
"""Skip calls to get data from API."""
|
|
with patch(
|
|
"custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data"
|
|
):
|
|
yield
|
|
|
|
|
|
# In this fixture, we are forcing calls to async_get_data to raise an Exception. This is useful
|
|
# for exception handling.
|
|
@pytest.fixture(name="error_on_get_data")
|
|
def error_get_data_fixture():
|
|
"""Simulate error when retrieving data from API."""
|
|
with patch(
|
|
"custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data",
|
|
side_effect=Exception,
|
|
):
|
|
yield
|