Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / home-assistant / tests.nix
blob3e493b722802615a953476e63d5e723e03e6787a
1 { lib
2 , home-assistant
3 }:
5 let
6   # some components' tests have additional dependencies
7   extraCheckInputs = with home-assistant.python.pkgs; {
8     airzone_cloud = [
9       aioairzone
10     ];
11     androidtv = home-assistant.getPackages "asuswrt" home-assistant.python.pkgs;
12     bluetooth = [
13       pyswitchbot
14     ];
15     govee_ble = [
16       ibeacon-ble
17     ];
18     lovelace = [
19       pychromecast
20     ];
21     matrix = [
22       pydantic
23     ];
24     mopeka = [
25       pyswitchbot
26     ];
27     onboarding = [
28       pymetno
29       radios
30       rpi-bad-power
31     ];
32     raspberry_pi = [
33       rpi-bad-power
34     ];
35     shelly = [
36       pyswitchbot
37     ];
38     tilt_ble = [
39       ibeacon-ble
40     ];
41     xiaomi_miio = [
42       arrow
43     ];
44     zha = [
45       pydeconz
46     ];
47   };
49   extraDisabledTestPaths = {
50   };
52   extraDisabledTests = {
53     advantage_air = [
54       # AssertionError: assert 2 == 1 (Expected two calls, got one)
55       "test_binary_sensor_async_setup_entry"
56     ];
57     hassio = [
58       # fails to load the hardware component
59       "test_device_registry_calls"
60     ];
61     husqvarna_automower = [
62       # snapshot mismatch
63       "test_device_diagnostics"
64     ];
65     recorder = [
66       # call not happening, likely due to timezone issues
67       "test_auto_purge"
68     ];
69     shell_command = [
70       # tries to retrieve file from github
71       "test_non_text_stdout_capture"
72     ];
73     sma = [
74       # missing operating_status attribute in entity
75       "test_sensor_entities"
76     ];
77     websocket_api = [
78       # racy
79       "test_render_template_with_timeout"
80     ];
81   };
83   extraPytestFlagsArray = {
84     cloud = [
85       # Tries to connect to alexa-api.nabucasa.com:443
86       "--deselect tests/components/cloud/test_http_api.py::test_websocket_update_preferences_alexa_report_state"
87     ];
88     dnsip = [
89       # Tries to resolve DNS entries
90       "--deselect tests/components/dnsip/test_config_flow.py::test_options_flow"
91     ];
92     jellyfin = [
93       # AssertionError: assert 'audio/x-flac' == 'audio/flac'
94       "--deselect tests/components/jellyfin/test_media_source.py::test_resolve"
95       "--deselect tests/components/jellyfin/test_media_source.py::test_audio_codec_resolve"
96       # AssertionError: assert [+ received] == [- snapshot]
97       "--deselect tests/components/jellyfin/test_media_source.py::test_music_library"
98     ];
99     modem_callerid = [
100       # aioserial mock produces wrong state
101       "--deselect tests/components/modem_callerid/test_init.py::test_setup_entry"
102     ];
103     velux = [
104       # uses unmocked sockets
105       "--deselect tests/components/velux/test_config_flow.py::test_user_success"
106       "--deselect tests/components/velux/test_config_flow.py::test_import_valid_config"
107     ];
108   };
109 in lib.listToAttrs (map (component: lib.nameValuePair component (
110   home-assistant.overridePythonAttrs (old: {
111     pname = "homeassistant-test-${component}";
112     pyproject = null;
113     format = "other";
115     dontBuild = true;
116     dontInstall = true;
118     nativeCheckInputs = old.nativeCheckInputs
119       ++ home-assistant.getPackages component home-assistant.python.pkgs
120       ++ extraCheckInputs.${component} or [ ];
122     disabledTests = old.disabledTests or [] ++ extraDisabledTests.${component} or [];
123     disabledTestPaths = old.disabledTestPaths or [] ++ extraDisabledTestPaths.${component} or [ ];
125     # components are more often racy than the core
126     dontUsePytestXdist = true;
128     pytestFlagsArray = lib.remove "tests" old.pytestFlagsArray
129       ++ extraPytestFlagsArray.${component} or [ ]
130       ++ [ "tests/components/${component}" ];
132     preCheck = old.preCheck + lib.optionalString (builtins.elem component [ "emulated_hue" "songpal" "system_log" ]) ''
133       patch -p1 < ${./patches/tests-mock-source-ip.patch}
134     '';
136     meta = old.meta // {
137       broken = lib.elem component [ ];
138       # upstream only tests on Linux, so do we.
139       platforms = lib.platforms.linux;
140     };
141   })
142 )) home-assistant.supportedComponentsWithTests)