Skip to content

Commit

Permalink
Avoid setup entry in config_flow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oncleben31 committed Jan 13, 2021
1 parent 742912d commit 5420be3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"""Test Cookiecutter Home Assistant Custom Component Instance config flow."""
from unittest.mock import patch

import pytest
from custom_components.cookiecutter_homeassistant_custom_component_instance.const import (
BINARY_SENSOR,
)
Expand All @@ -21,10 +24,23 @@
from .const import MOCK_CONFIG


@pytest.fixture(autouse=True)
def bypass_setup_fixture():
"""Prevent setup."""
with patch(
"custom_components.cookiecutter_homeassistant_custom_component_instance.async_setup",
return_value=True,
), patch(
"custom_components.cookiecutter_homeassistant_custom_component_instance.async_setup_entry",
return_value=True,
):
yield


# Here we simiulate a successful config flow from the backend.
# Note that we use the `bypass_get_data` fixture here because
# we want the config flow validation to succeed during the test.
async def test_successful_config_flow(hass, bypass_get_data):
async def test_successful_config_flow(hass, bypass_get_data, bypass_setup_fixture):
"""Test a successful config flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
Expand Down

0 comments on commit 5420be3

Please sign in to comment.