Explorar o código

Update tests for latest changes.

- update version of pytest-homeassistant-custom-component to one that recognises EntityCategory enums.
- update unit tests to work correctly.

Currently a full test run starts giving errors after 955 tests due to a resource leak somewhere in the newer versions of the framework.
Jason Rumney %!s(int64=4) %!d(string=hai) anos
pai
achega
28f561170a
Modificáronse 2 ficheiros con 7 adicións e 5 borrados
  1. 1 1
      requirements-dev.txt
  2. 6 4
      tests/devices/base_device_tests.py

+ 1 - 1
requirements-dev.txt

@@ -1,6 +1,6 @@
 black
 isort
-pytest-homeassistant-custom-component==0.4.5
+pytest-homeassistant-custom-component~=0.8.4
 pytest
 pytest-asyncio
 pytest-cov

+ 6 - 4
tests/devices/base_device_tests.py

@@ -2,6 +2,8 @@ from unittest import IsolatedAsyncioTestCase
 from unittest.mock import AsyncMock, patch, PropertyMock
 from uuid import uuid4
 
+from homeassistant.helpers.entity import EntityCategory
+
 from custom_components.tuya_local.generic.binary_sensor import TuyaLocalBinarySensor
 from custom_components.tuya_local.generic.climate import TuyaLocalClimate
 from custom_components.tuya_local.generic.cover import TuyaLocalCover
@@ -99,14 +101,14 @@ class TuyaDeviceTestCase(IsolatedAsyncioTestCase):
                 if type(e) in [TuyaLocalBinarySensor, TuyaLocalSensor]:
                     self.assertEqual(
                         e.entity_category,
-                        "diagnostic",
-                        msg=f"{k} is {e.entity_category}, expected diagnostic",
+                        EntityCategory.DIAGNOSTIC,
+                        msg=f"{k} is {e.entity_category.value}, expected diagnostic",
                     )
                 else:
                     self.assertEqual(
                         e.entity_category,
-                        "config",
-                        msg=f"{k} is {e.entity_category}, expected config",
+                        EntityCategory.CONFIG,
+                        msg=f"{k} is {e.entity_category.value}, expected config",
                     )
             else:
                 self.assertIsNone(