mastodon: 4.3.1 -> 4.3.2 (#361487)
[NixPkgs.git] / pkgs / servers / home-assistant / tests.nix
blob10389600386c2dd12eaa96b90df988c0087834ec
1 { lib
2 , home-assistant
3 }:
5 let
6   getComponentDeps = component: home-assistant.getPackages component home-assistant.python.pkgs;
8   # some components' tests have additional dependencies
9   extraCheckInputs = with home-assistant.python.pkgs; {
10     axis = getComponentDeps "deconz";
11     gardena_bluetooth = getComponentDeps "husqvarna_automower_ble";
12     govee_ble = [
13       ibeacon-ble
14     ];
15     hassio = getComponentDeps "homeassistant_yellow";
16     husqvarna_automower_ble = getComponentDeps "gardena_bluetooth";
17     lovelace = [
18       pychromecast
19     ];
20     matrix = [
21       pydantic
22     ];
23     onboarding = [
24       pymetno
25       radios
26       rpi-bad-power
27     ];
28     raspberry_pi = [
29       rpi-bad-power
30     ];
31     shelly = [
32       pyswitchbot
33     ];
34     songpal = [
35       isal
36     ];
37     system_log = [
38       isal
39     ];
40     tesla_fleet = getComponentDeps "teslemetry";
41     xiaomi_miio = [
42       arrow
43     ];
44     zeroconf = [
45       aioshelly
46     ];
47     zha = [
48       pydeconz
49     ];
50   };
52   extraDisabledTestPaths = {
53   };
55   extraDisabledTests = {
56     shell_command = [
57       # tries to retrieve file from github
58       "test_non_text_stdout_capture"
59     ];
60     sma = [
61       # missing operating_status attribute in entity
62       "test_sensor_entities"
63     ];
64     websocket_api = [
65       # AssertionError: assert 'unknown_error' == 'template_error'
66       "test_render_template_with_timeout"
67     ];
68   };
70   extraPytestFlagsArray = {
71     conversation = [
72       # Expected:  Sorry, I am not aware of any device called missing entity on ground floor
73       # Actually:  Sorry, I am not aware of any area called ground floor
74       "--deselect tests/components/conversation/test_default_agent.py::test_error_no_device_on_floor"
75     ];
76     dnsip = [
77       # Tries to resolve DNS entries
78       "--deselect tests/components/dnsip/test_config_flow.py::test_options_flow"
79     ];
80     honeywell = [
81       # Failed: Unused ignore translations: component.honeywell.config.abort.reauth_successful. Please remove them from the ignore_translations fixture.
82       "--deselect=tests/components/honeywell/test_config_flow.py::test_reauth_flow"
83     ];
84     jellyfin = [
85       # AssertionError: assert 'audio/x-flac' == 'audio/flac'
86       "--deselect tests/components/jellyfin/test_media_source.py::test_resolve"
87       "--deselect tests/components/jellyfin/test_media_source.py::test_audio_codec_resolve"
88       # AssertionError: assert [+ received] == [- snapshot]
89       "--deselect tests/components/jellyfin/test_media_source.py::test_music_library"
90     ];
91     jewish_calendar = [
92       # Failed: Unused ignore translations: component.jewish_calendar.config.abort.reconfigure_successful. Please remove them from the ignore_translations fixture.
93       "--deselect tests/components/jewish_calendar/test_config_flow.py::test_reconfigure"
94     ];
95     modem_callerid = [
96       # aioserial mock produces wrong state
97       "--deselect tests/components/modem_callerid/test_init.py::test_setup_entry"
98     ];
99     nina = [
100       # Failed: Unused ignore translations: component.nina.options.error.unknown. Please remove them from the ignore_translations fixture.
101       "--deselect tests/components/nina/test_config_flow.py::test_options_flow_unexpected_exception"
102     ];
103     sql = [
104       "-W"
105       "ignore::sqlalchemy.exc.SAWarning"
106     ];
107     vicare = [
108       # Snapshot 'test_all_entities[sensor.model0_electricity_consumption_today-entry]' does not exist!
109       "--deselect=tests/components/vicare/test_sensor.py::test_all_entities"
110     ];
111   };
112 in lib.listToAttrs (map (component: lib.nameValuePair component (
113   home-assistant.overridePythonAttrs (old: {
114     pname = "homeassistant-test-${component}";
115     pyproject = null;
116     format = "other";
118     dontBuild = true;
119     dontInstall = true;
121     nativeCheckInputs = old.nativeCheckInputs
122       ++ home-assistant.getPackages component home-assistant.python.pkgs
123       ++ extraCheckInputs.${component} or [ ];
125     disabledTests = old.disabledTests or [] ++ extraDisabledTests.${component} or [];
126     disabledTestPaths = old.disabledTestPaths or [] ++ extraDisabledTestPaths.${component} or [ ];
128     # components are more often racy than the core
129     dontUsePytestXdist = true;
131     pytestFlagsArray = lib.remove "tests" old.pytestFlagsArray
132       ++ extraPytestFlagsArray.${component} or [ ]
133       ++ [ "tests/components/${component}" ];
135     preCheck = old.preCheck + lib.optionalString (builtins.elem component [ "emulated_hue" "songpal" "system_log" ]) ''
136       patch -p1 < ${./patches/tests-mock-source-ip.patch}
137     '';
139     meta = old.meta // {
140       broken = lib.elem component [ ];
141       # upstream only tests on Linux, so do we.
142       platforms = lib.platforms.linux;
143     };
144   })
145 )) home-assistant.supportedComponentsWithTests)