forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning to custom integrations without version (home-assistant#45919
) Co-authored-by: Paulus Schoutsen <[email protected]>
- Loading branch information
Showing
9 changed files
with
173 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Tests for hassfest version.""" | ||
import pytest | ||
import voluptuous as vol | ||
|
||
from script.hassfest.manifest import ( | ||
CUSTOM_INTEGRATION_MANIFEST_SCHEMA, | ||
validate_version, | ||
) | ||
from script.hassfest.model import Integration | ||
|
||
|
||
@pytest.fixture | ||
def integration(): | ||
"""Fixture for hassfest integration model.""" | ||
integration = Integration("") | ||
integration.manifest = { | ||
"domain": "test", | ||
"documentation": "https://example.com", | ||
"name": "test", | ||
"codeowners": ["@awesome"], | ||
} | ||
return integration | ||
|
||
|
||
def test_validate_version_no_key(integration: Integration): | ||
"""Test validate version with no key.""" | ||
validate_version(integration) | ||
assert ( | ||
"No 'version' key in the manifest file. This will cause a future version of Home Assistant to block this integration." | ||
in [x.error for x in integration.warnings] | ||
) | ||
|
||
|
||
def test_validate_custom_integration_manifest(integration: Integration): | ||
"""Test validate custom integration manifest.""" | ||
|
||
with pytest.raises(vol.Invalid): | ||
integration.manifest["version"] = "lorem_ipsum" | ||
CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest) | ||
|
||
with pytest.raises(vol.Invalid): | ||
integration.manifest["version"] = None | ||
CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest) | ||
|
||
integration.manifest["version"] = "1" | ||
schema = CUSTOM_INTEGRATION_MANIFEST_SCHEMA(integration.manifest) | ||
assert schema["version"] == "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters