diff --git a/pkgs/servers/home-assistant/custom-components/govee-lan/default.nix b/pkgs/servers/home-assistant/custom-components/govee-lan/default.nix index 60c58bb85850..f5ab54f19329 100644 --- a/pkgs/servers/home-assistant/custom-components/govee-lan/default.nix +++ b/pkgs/servers/home-assistant/custom-components/govee-lan/default.nix @@ -1,7 +1,10 @@ { lib , buildHomeAssistantComponent , fetchFromGitHub +, fetchpatch2 , govee-led-wez +, pytest-homeassistant-custom-component +, pytestCheckHook }: buildHomeAssistantComponent { @@ -16,19 +19,32 @@ buildHomeAssistantComponent { hash = "sha256-ZhrxEPBEi+Z+2ZOAQ1amhO0tqvhM6tyFQgoRIVNDtXY="; }; + patches = [ + (fetchpatch2 { + url = "https://github.com/wez/govee-lan-hass/commit/b4cecac5ae00d95c49fcfe3bbfc405cbfc5dd84c.patch"; + hash = "sha256-+MPO4kxxE1nZ/+sIY7v8WukHMrVowgMMBVfRDw2uv8o="; + }) + ]; + + postPatch = '' + substituteInPlace setup.cfg \ + --replace-fail "--cov=custom_components" "" + ''; + dontBuild = true; propagatedBuildInputs = [ govee-led-wez ]; - # enable when pytest-homeassistant-custom-component is packaged + # AttributeError: 'async_generator' object has no attribute 'config' doCheck = false; - # nativeCheckInputs = [ - # pytest-homeassistant-custom-component - # pytestCheckHook - # ]; + nativeCheckInputs = [ + pytest-homeassistant-custom-component + pytestCheckHook + ]; + meta = with lib; { description = "Control Govee lights via the LAN API from Home Assistant"; diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix index 3d64bf38457d..0aca399b8931 100644 --- a/pkgs/servers/home-assistant/default.nix +++ b/pkgs/servers/home-assistant/default.nix @@ -455,6 +455,8 @@ let # internal python packages only consumed by home-assistant itself home-assistant-frontend = self.callPackage ./frontend.nix { }; home-assistant-intents = self.callPackage ./intents.nix { }; + homeassistant = self.toPythonModule home-assistant; + pytest-homeassistant-custom-component = self.callPackage ./pytest-homeassistant-custom-component.nix { }; }) ]; diff --git a/pkgs/servers/home-assistant/pytest-homeassistant-custom-component.nix b/pkgs/servers/home-assistant/pytest-homeassistant-custom-component.nix new file mode 100644 index 000000000000..c3c9deec7f22 --- /dev/null +++ b/pkgs/servers/home-assistant/pytest-homeassistant-custom-component.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + pythonOlder, + fetchFromGitHub, + setuptools, + aiohttp, + bcrypt, + freezegun, + homeassistant, + pytest-asyncio, + pytest-socket, + requests-mock, + syrupy, + pytestCheckHook, +}: + +buildPythonPackage rec { + pname = "pytest-homeassistant-custom-component"; + version = "0.13.147"; + pyproject = true; + + disabled = pythonOlder "3.12"; + + src = fetchFromGitHub { + owner = "MatthewFlamm"; + repo = "pytest-homeassistant-custom-component"; + rev = "refs/tags/${version}"; + hash = "sha256-FivgP0tKmu9QKPSVU9c/3SNduyKoSeAquHysdHSs11E="; + }; + + build-system = [ setuptools ]; + + pythonRemoveDeps = true; + + dependencies = [ + aiohttp + bcrypt + freezegun + homeassistant + pytest-asyncio + pytest-socket + requests-mock + syrupy + ]; + + pythonImportsCheck = [ "pytest_homeassistant_custom_component.plugins" ]; + + nativeCheckInputs = [ pytestCheckHook ]; + + meta = { + changelog = "https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/blob/${src.rev}/CHANGELOG.md"; + description = "Package to automatically extract testing plugins from Home Assistant for custom component testing"; + homepage = "https://github.com/MatthewFlamm/pytest-homeassistant-custom-component"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ dotlambda ]; + }; +}