test_mac_address.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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 pytest
  19. import switchbot_mqtt
  20. @pytest.mark.parametrize(
  21. ("mac_address", "valid"),
  22. [
  23. ("aa:bb:cc:dd:ee:ff", True),
  24. ("AA:BB:CC:DD:EE:FF", True),
  25. ("AA:12:34:45:67:89", True),
  26. ("aabbccddeeff", False), # not supported by PySwitchbot
  27. ("aa:bb:cc:dd:ee:gg", False),
  28. ],
  29. )
  30. def test__mac_address_valid(mac_address, valid):
  31. # pylint: disable=protected-access
  32. assert switchbot_mqtt._mac_address_valid(mac_address) == valid