-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(feature_support): remove unnecessary code
- Loading branch information
Showing
18 changed files
with
137 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,8 @@ | ||
from cx_core.feature_support import FeatureSupport | ||
|
||
|
||
class LightSupport(FeatureSupport): | ||
class LightSupport: | ||
BRIGHTNESS = 1 | ||
COLOR_TEMP = 2 | ||
EFFECT = 4 | ||
FLASH = 8 | ||
COLOR = 16 | ||
TRANSITION = 32 | ||
WHITE_VALUE = 128 | ||
|
||
features = [ | ||
BRIGHTNESS, | ||
COLOR_TEMP, | ||
EFFECT, | ||
FLASH, | ||
COLOR, | ||
TRANSITION, | ||
WHITE_VALUE, | ||
] |
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
29 changes: 19 additions & 10 deletions
29
tests/unit_tests/cx_core/feature_support/cover_support_test.py
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 |
---|---|---|
@@ -1,33 +1,42 @@ | ||
from typing import List | ||
|
||
import pytest | ||
from cx_core.feature_support import FeatureSupport, SupportedFeatures | ||
from cx_core.feature_support import FeatureSupport | ||
from cx_core.feature_support.cover import CoverSupport | ||
from cx_core.type_controller import TypeController | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"number, expected_supported_features", | ||
[ | ||
(1, {CoverSupport.OPEN}), | ||
(1, [CoverSupport.OPEN]), | ||
( | ||
15, | ||
{ | ||
[ | ||
CoverSupport.OPEN, | ||
CoverSupport.CLOSE, | ||
CoverSupport.SET_COVER_POSITION, | ||
CoverSupport.STOP, | ||
}, | ||
], | ||
), | ||
( | ||
149, | ||
{ | ||
[ | ||
CoverSupport.SET_TILT_POSITION, | ||
CoverSupport.OPEN_TILT, | ||
CoverSupport.SET_COVER_POSITION, | ||
CoverSupport.OPEN, | ||
}, | ||
], | ||
), | ||
(0, set()), | ||
], | ||
) | ||
def test_decode(number: int, expected_supported_features: SupportedFeatures): | ||
supported_features = FeatureSupport.decode(number, CoverSupport.features) | ||
assert supported_features == expected_supported_features | ||
@pytest.mark.asyncio | ||
async def test_is_supported( | ||
fake_type_controller: TypeController, | ||
number: int, | ||
expected_supported_features: List[int], | ||
): | ||
feature_support = FeatureSupport("fake_entity", fake_type_controller, False) | ||
feature_support._supported_features = number | ||
for expected_supported_feature in expected_supported_features: | ||
assert await feature_support.is_supported(expected_supported_feature) |
Oops, something went wrong.