1
0

test_actor_base.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # switchbot-mqtt - MQTT client controlling SwitchBot button & curtain automators,
  2. # compatible with home-assistant.io's MQTT Switch & Cover platform
  3. #
  4. # Copyright (C) 2020 Fabian Peter Hammerle <fabian@hammerle.me>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. import paho.mqtt.client
  19. import pytest
  20. import switchbot_mqtt
  21. # pylint: disable=protected-access
  22. def test_abstract():
  23. with pytest.raises(TypeError, match=r"\babstract class\b"):
  24. # pylint: disable=abstract-class-instantiated
  25. switchbot_mqtt._MQTTControlledActor(mac_address=None)
  26. def test_execute_command_abstract():
  27. class _ActorMock(switchbot_mqtt._MQTTControlledActor):
  28. def execute_command(
  29. self, mqtt_message_payload: bytes, mqtt_client: paho.mqtt.client.Client
  30. ) -> None:
  31. super().execute_command(
  32. mqtt_message_payload=mqtt_message_payload, mqtt_client=mqtt_client
  33. )
  34. actor = _ActorMock(mac_address=None)
  35. with pytest.raises(NotImplementedError):
  36. actor.execute_command(mqtt_message_payload=b"dummy", mqtt_client="dummy")