Unverified Commit c76b72ca authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

Merge pull request #270456 from mweinelt/hass-cleanup

home-assistant: some clean up
parents f72ea957 c1508779
Loading
Loading
Loading
Loading
+26 −37
Original line number Diff line number Diff line
@@ -352,30 +352,12 @@ in python.pkgs.buildPythonApplication rec {
  };

  nativeBuildInputs = with python.pkgs; [
    pythonRelaxDepsHook
    setuptools
    wheel
  ];

  # copy tests early, so patches apply as they would to the git repo
  prePatch = ''
    cp --no-preserve=mode --recursive ${gitSrc}/tests ./
    chmod u+x tests/auth/providers/test_command_line_cmd.sh
  '';

  # leave this in, so users don't have to constantly update their downstream patch handling
  patches = [
    # Follow symlinks in /var/lib/hass/www
    ./patches/static-symlinks.patch

    # Patch path to ffmpeg binary
    (substituteAll {
      src = ./patches/ffmpeg-path.patch;
      ffmpeg = "${lib.getBin ffmpeg-headless}/bin/ffmpeg";
    })
  ];

  postPatch = let
    relaxedConstraints = [
  pythonRelaxDeps = [
    "aiohttp"
    "attrs"
    "awesomeversion"
@@ -395,12 +377,26 @@ in python.pkgs.buildPythonApplication rec {
    "voluptuous-serialize"
    "yarl"
  ];
  in ''
    sed -r -i \
      ${lib.concatStringsSep "\n" (map (package:
        ''-e 's/${package}[<>=]+.*/${package}",/g' \''
      ) relaxedConstraints)}
      pyproject.toml

  # copy tests early, so patches apply as they would to the git repo
  prePatch = ''
    cp --no-preserve=mode --recursive ${gitSrc}/tests ./
    chmod u+x tests/auth/providers/test_command_line_cmd.sh
  '';

  # leave this in, so users don't have to constantly update their downstream patch handling
  patches = [
    # Follow symlinks in /var/lib/hass/www
    ./patches/static-symlinks.patch

    # Patch path to ffmpeg binary
    (substituteAll {
      src = ./patches/ffmpeg-path.patch;
      ffmpeg = "${lib.getBin ffmpeg-headless}/bin/ffmpeg";
    })
  ];

  postPatch = ''
    substituteInPlace tests/test_config.py --replace '"/usr"' '"/build/media"'

    sed -i 's/setuptools[~=]/setuptools>/' pyproject.toml
@@ -436,6 +432,9 @@ in python.pkgs.buildPythonApplication rec {
    voluptuous
    voluptuous-serialize
    yarl
    # REQUIREMENTS in homeassistant/auth/mfa_modules/totp.py and homeassistant/auth/mfa_modules/notify.py
    pyotp
    pyqrcode
    # Implicit dependency via homeassistant/requirements.py
    setuptools
  ];
@@ -462,16 +461,12 @@ in python.pkgs.buildPythonApplication rec {
    respx
    syrupy
    tomli
    # required through tests/auth/mfa_modules/test_otp.py
    pyotp
    # Sneakily imported in tests/conftest.py
    paho-mqtt
  ] ++ lib.concatMap (component: getPackages component python.pkgs) [
    # some components are needed even if tests in tests/components are disabled
    "default_config"
    "hue"
    # for tests/test_config.py::test_merge_id_schema
    "qwikswitch"
  ];

  pytestFlagsArray = [
@@ -484,12 +479,6 @@ in python.pkgs.buildPythonApplication rec {
    "--showlocals"
    # AssertionError: assert 1 == 0
    "--deselect tests/test_config.py::test_merge"
    # AssertionError: assert 2 == 1
    "--deselect=tests/helpers/test_translation.py::test_caching"
    # AssertionError: assert None == RegistryEntry
    "--deselect=tests/helpers/test_entity_registry.py::test_get_or_create_updates_data"
    # AssertionError: assert 2 == 1
    "--deselect=tests/helpers/test_entity_values.py::test_override_single_value"
    # AssertionError: assert 'WARNING' not in '2023-11-10 ...nt abc[L]>\n'"
    "--deselect=tests/helpers/test_script.py::test_multiple_runs_repeat_choose"
    # tests are located in tests/