about summary refs log tree commit diff
path: root/pkgs/servers/home-assistant/tests.nix
blob: 9b8c04432026bf48157a09cc68b3e2d6db851f94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{ lib
, home-assistant
}:

let
  # some components' tests have additional dependencies
  extraCheckInputs = with home-assistant.python.pkgs; {
    alexa = [ av ];
    bluetooth = [ pyswitchbot ];
    bthome = [ xiaomi-ble ];
    camera = [ av ];
    cloud = [ mutagen ];
    config = [ pydispatcher ];
    generic = [ av ];
    google_translate = [ mutagen ];
    google_sheets = [ oauth2client ];
    govee_ble = [ ibeacon-ble ];
    hassio = [ bellows zha-quirks zigpy-deconz zigpy-xbee zigpy-zigate zigpy-znp ];
    homeassistant_sky_connect = [ bellows zha-quirks zigpy-deconz zigpy-xbee zigpy-zigate zigpy-znp zwave-js-server-python ];
    homeassistant_yellow = [ bellows zha-quirks zigpy-deconz zigpy-xbee zigpy-zigate zigpy-znp ];
    lovelace = [ PyChromecast ];
    nest = [ av ];
    onboarding = [ pymetno radios rpi-bad-power ];
    raspberry_pi = [ rpi-bad-power ];
    shelly = [ pyswitchbot ];
    tilt_ble = [ govee-ble ibeacon-ble ];
    tomorrowio = [ pyclimacell ];
    version = [ aioaseko ];
    xiaomi_miio = [ arrow ];
    voicerss = [ mutagen ];
    yandextts = [ mutagen ];
    zha = [ pydeconz ];
    zwave_js = [ homeassistant-pyozw ];
  };

  extraDisabledTestPaths = {
    tado = [
      # tado/test_{climate,water_heater}.py: Tries to connect to my.tado.com
      "tests/components/tado/test_climate.py"
      "tests/components/tado/test_water_heater.py"
    ];
  };

  extraDisabledTests = {
    roku = [
      # homeassistant.components.roku.media_player:media_player.py:428 Media type music is not supported with format None (mime: audio/x-matroska)
      "test_services_play_media_audio"
    ];
    rfxtrx = [
      # bytearrray mismatch
      "test_rfy_cover"
    ];
    zha = [
      # 'manual_pick_radio_type' == 'choose_serial_port'
      "test_options_flow_migration_reset_old_adapter"
    ];
  };

  extraPytestFlagsArray = {
    asuswrt = [
      # Sandbox network limitations, fails with unexpected error
      "--deselect tests/components/asuswrt/test_config_flow.py::test_on_connect_failed"
    ];
    dnsip = [
      # AssertionError: assert <FlowResultType.FORM: 'form'> == <FlowResultTy...create_entry'>
      "--deselect tests/components/dnsip/test_config_flow.py::test_options_flow"
    ];
    history_stats = [
      # Flaky: AssertionError: assert '0.0' == '12.0'
      "--deselect tests/components/history_stats/test_sensor.py::test_end_time_with_microseconds_zeroed"
    ];
    modem_callerid = [
      # aioserial mock produces wrong state
      "--deselect tests/components/modem_callerid/test_init.py::test_setup_entry"
    ];
    unifiprotect = [
      # "TypeError: object Mock can't be used in 'await' expression
      "--deselect tests/components/unifiprotect/test_repairs.py::test_ea_warning_fix"
    ];
    skybell = [
      # Sandbox network limitations: Cannot connect to host cloud.myskybell.com:443
      "--deselect tests/components/skybell/test_config_flow.py::test_flow_user_unknown_error"
    ];
    stream = [
      # Tries to write to /example and gets "Permission denied"
      "--deselect tests/components/stream/test_recorder.py::test_record_lookback"
      "--deselect tests/components/stream/test_recorder.py::test_recorder_log"
      "--deselect tests/components/stream/test_worker.py::test_get_image"
    ];
    zha = [
      # AssertionError: assert 'manual_pick_radio_type' == 'choose_serial_port'
      "--deselect tests/components/zha/test_config_flow.py::test_options_flow_restarts_running_zha_if_cancelled"
    ];
  };
in lib.listToAttrs (map (component: lib.nameValuePair component (
  home-assistant.overridePythonAttrs (old: {
    pname = "homeassistant-test-${component}";
    format = "other";

    dontBuild = true;
    dontInstall = true;

    checkInputs = old.checkInputs
      ++ home-assistant.getPackages component home-assistant.python.pkgs
      ++ extraCheckInputs.${component} or [ ];

    disabledTests = old.disabledTests ++ extraDisabledTests.${component} or [];
    disabledTestPaths = old.disabledTestPaths ++ extraDisabledTestPaths.${component} or [ ];

    # components are more often racy than the core
    dontUsePytestXdist = true;

    pytestFlagsArray = lib.remove "tests" old.pytestFlagsArray
      ++ [ "--numprocesses=4" ]
      ++ extraPytestFlagsArray.${component} or [ ]
      ++ [ "tests/components/${component}" ];

    preCheck = old.preCheck + lib.optionalString (builtins.elem component [ "emulated_hue" "songpal" "system_log" ]) ''
      patch -p1 < ${./patches/tests-mock-source-ip.patch}
    '';

    meta = old.meta // {
      broken = lib.elem component [
         # all tests are skipped
         # https://github.com/home-assistant/core/blob/dev/tests/components/homeassistant_hardware/test_silabs_multiprotocol_addon.py#L23
        "homeassistant_hardware"
      ];
      # upstream only tests on Linux, so do we.
      platforms = lib.platforms.linux;
    };
  })
)) home-assistant.supportedComponentsWithTests)