Use parametrize to modify Axis test fixtures (#85884)

This commit is contained in:
Robert Svensson 2023-01-15 04:12:03 +01:00 committed by GitHub
parent 3627a98602
commit 8117f4af3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 20 deletions

View File

@ -54,15 +54,8 @@ def config_entry_fixture(hass, config, options, config_entry_version):
@pytest.fixture(name="config_entry_version")
def config_entry_version_fixture(request):
"""Define a config entry version fixture.
@pytest.mark.config_entry_version(int)
"""
marker = request.node.get_closest_marker("config_entry_version")
version = 3
if marker:
version = marker.args[0]
return version
"""Define a config entry version fixture."""
return 3
@pytest.fixture(name="config")
@ -73,15 +66,8 @@ def config_fixture():
@pytest.fixture(name="options")
def options_fixture(request):
"""Define a config entry options fixture.
@pytest.mark.config_entry_options(dict)
"""
marker = request.node.get_closest_marker("config_entry_options")
options = ENTRY_OPTIONS.copy()
if marker:
options = marker.args[0]
return options
"""Define a config entry options fixture."""
return ENTRY_OPTIONS.copy()
@pytest.fixture(autouse=True)

View File

@ -50,7 +50,7 @@ async def test_camera(hass, config_entry):
)
@pytest.mark.config_entry_options({CONF_STREAM_PROFILE: "profile_1"})
@pytest.mark.parametrize("options", [{CONF_STREAM_PROFILE: "profile_1"}])
async def test_camera_with_stream_profile(hass, config_entry):
"""Test that Axis camera entity is using the correct path with stream profike."""
await setup_axis_integration(hass, config_entry)

View File

@ -45,7 +45,7 @@ async def test_unload_entry(hass, config_entry):
assert not hass.data[AXIS_DOMAIN]
@pytest.mark.config_entry_version(1)
@pytest.mark.parametrize("config_entry_version", [1])
async def test_migrate_entry(hass, config_entry):
"""Test successful migration of entry data."""
assert config_entry.version == 1