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)
async def test_not_supported(
    fake_type_controller: TypeController,
    number: int,
    feature: int,
    expected_is_supported: bool,
):
    feature_support = FeatureSupport("fake_entity", fake_type_controller,
                                     False)
    feature_support._supported_features = number
    is_supported = await feature_support.not_supported(feature)
    assert is_supported == expected_is_supported
 async def init(self) -> None:
     if self.entity_arg not in self.args:
         raise ValueError(
             f"{self.__class__.__name__} class needs the `{self.entity_arg}` attribute"
         )
     self.entity = self.get_entity(self.args[self.entity_arg])  # type: ignore
     await self.check_domain(self.entity.name)
     update_supported_features = self.args.get("update_supported_features", False)
     self.feature_support = FeatureSupport(
         self.entity.name, self, update_supported_features
     )
     await super().init()
Exemple #4
0
 async def init(self) -> None:
     if self.entity_arg not in self.args:
         raise ValueError(
             f"{self.__class__.__name__} class needs the `{self.entity_arg}` attribute"
         )
     self.entity = await self._get_entity(self.args[self.entity_arg])
     self._check_domain(self.entity)
     self.update_supported_features = self.args.get(
         "update_supported_features", False)
     supported_features: Optional[int] = self.args.get("supported_features")
     self.feature_support = FeatureSupport(self, supported_features,
                                           self.update_supported_features)
     await super().init()
Exemple #5
0
def test_init(number, expected_supported_features):
    cover_support = CoverSupport(None, None, False)
    cover_support._supported_features = FeatureSupport.decode(
        number, cover_support.features
    )
    assert cover_support._supported_features == expected_supported_features
def test_init(number, expected_supported_features):
    light_support = LightSupport(None, None, False)
    light_support._supported_features = FeatureSupport.decode(
        number, light_support.features)
    assert light_support._supported_features == expected_supported_features
Exemple #7
0
def test_init(number, expected_supported_features):
    media_player_support = MediaPlayerSupport(None, None, False)
    media_player_support._supported_features = FeatureSupport.decode(
        number, media_player_support.features
    )
    assert media_player_support._supported_features == expected_supported_features