mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
Remove invalidation_version from deprecated (#44156)
* Remove invalidation_version from deprecated. We don't follow up and just hurts releases * Revert change to ZHA
This commit is contained in:
@@ -698,116 +698,6 @@ def test_deprecated_with_replacement_key(caplog, schema):
|
||||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_invalidation_version(caplog, schema, version):
|
||||
"""
|
||||
Test deprecation behaves correctly with only an invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema without changing any values
|
||||
- No warning or difference in output if key is not provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="9999.99.9"), schema
|
||||
)
|
||||
|
||||
message = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. "
|
||||
"This option will become invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert message in caplog.text
|
||||
assert test_data == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"venus": False}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="0.1.0"), schema
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_and_invalidation_version(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation behaves with a replacement key & invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning or difference in output if neither key nor
|
||||
replacement_key are provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars", replacement_key="jupiter", invalidation_version="9999.99.9"
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
warning = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert warning in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_default(caplog, schema):
|
||||
"""
|
||||
Test deprecation behaves correctly with a default value.
|
||||
@@ -894,69 +784,6 @@ def test_deprecated_with_replacement_key_and_default(caplog, schema):
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_invalidation_version_default(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation with a replacement key, invalidation_version & default.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning if neither key nor replacement_key are provided
|
||||
- Adds replacement_key with default value in this case
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="9999.99.9",
|
||||
default=False,
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
) in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert {"venus": True, "jupiter": False} == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_cant_find_module():
|
||||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
@@ -964,7 +791,6 @@ def test_deprecated_cant_find_module():
|
||||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="1.0.0",
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user