@ -10,15 +10,12 @@
# self: super: { pkg = super.pkg.overridePythonAttrs (oldAttrs: { ... }); }
# Applied after defaultOverrides
, packageOverrides ? self : super : {
# TODO: Remove this override after updating to cryptography 2.8:
}
# Skip pip install of required packages on startup
, skipPip ? true } :
let
defaultOverrides = [
# Override the version of some packages pinned in Home Assistant's setup.py
@ -87,6 +84,14 @@ in with py.pkgs; buildPythonApplication rec {
sha256 = " 1 b q p k 9 d p r a 5 3 y h a s m p 0 y b 7 k z m f w d v l h b 7 j r f 6 w y v 1 2 r w z f 8 w y 5 w 7 " ;
} ;
patches = [
( fetchpatch {
# Fix group tests when run in parallel, remove >= 0.117.0
url = " h t t p s : / / g i t h u b . c o m / h o m e - a s s i s t a n t / c o r e / p u l l / 4 1 4 4 6 / c o m m i t s / c 7 9 d c 4 7 8 b 7 1 3 6 b 6 d f 4 3 7 0 7 b f 0 a d 6 b 5 3 4 1 9 c 8 a 9 0 9 . p a t c h " ;
sha256 = " 1 c l 8 1 s w q 9 6 0 v d 2 f 7 3 3 d c q q 6 0 c 0 j j z r k m 0 l 2 s i b c b l h m y w 5 9 7 b 4 v j " ;
} )
] ;
postPatch = ''
substituteInPlace setup . py \
- - replace " c r y p t o g r a p h y = = 2 . 9 . 2 " " c r y p t o g r a p h y " \
@ -100,37 +105,84 @@ in with py.pkgs; buildPythonApplication rec {
aiohttp astral async-timeout attrs bcrypt certifi importlib-metadata jinja2
pyjwt cryptography pip python-slugify pytz pyyaml requests ruamel_yaml
setuptools voluptuous voluptuous-serialize
# From frontend, image, http and recorder components and auth.mfa_modules.totp
sqlalchemy aiohttp-cors hass-frontend pillow pyotp pyqrcode ciso8601
# From default_config. frontend, http, image, mobile_app and recorder components as well as
# the auth.mfa_modules.totp module
aiohttp-cors ciso8601 defusedxml distro emoji hass-frontend pynacl pillow pyotp
pyqrcode sqlalchemy
] ++ componentBuildInputs ++ extraBuildInputs ;
# upstream only tests on Linux, so do we.
doCheck = stdenv . isLinux ;
checkInputs = [
asynctest pytest pytest-aiohttp requests-mock hass-nabucasa netdisco pydispatcher
asynctest pytestCheckHook pytest-aiohttp pytest_xdist requests-mock hass-nabucasa netdisco pydispatcher
] ;
checkPhase = ''
# We cannot test all components, since they'd introduce lots of dependencies, some of which are unpackaged,
# but we should test very common stuff, like what's in `default_config`.
componentTests = [
" a p i "
" a u t o m a t i o n "
" c o n f i g "
" c o n f i g u r a t o r "
" d e f a u l t _ c o n f i g "
" d e m o "
" d i s c o v e r y "
" f r o n t e n d "
" g r o u p "
" h i s t o r y "
" h o m e a s s i s t a n t "
" h t t p "
" i n p u t _ b o o l e a n "
" i n p u t _ d a t e t i m e "
" i n p u t _ t e x t "
" i n p u t _ n u m b e r "
" i n p u t _ s e l e c t "
" l o g b o o k "
" l o g g e r "
" m e d i a _ s o u r c e "
" m o b i l e _ a p p "
" p e r s o n "
" s c e n e "
" s c r i p t "
" s h e l l _ c o m m a n d "
" s s d p "
" s u n "
" s y s t e m _ h e a l t h "
" s y s t e m _ l o g "
" t a g "
" w e b s o c k e t _ a p i "
" z e r o c o n f "
" z o n e "
] ;
pytestFlagsArray = [
" - n a u t o "
# don't bulk test all components
" - - i g n o r e t e s t s / c o m p o n e n t s "
# prone to race conditions due to parallel file access
" - - i g n o r e t e s t s / t e s t _ c o n f i g . p y "
# tries to import unpackaged dependencies
" - - i g n o r e t e s t s / t e s t _ l o a d e r . p y "
# pyotp since v2.4.0 complains about the short mock keys, hass pins v2.3.0
" - - i g n o r e t e s t s / a u t h / m f a _ m o d u l e s / t e s t _ n o t i f y . p y "
" t e s t s "
] ++ map ( component : " t e s t s / c o m p o n e n t s / " + component ) componentTests ;
disabledTests = [
# AssertionError: merge_log_err.call_count != 0
" t e s t _ m e r g e "
# ModuleNotFoundError: No module named 'pyqwikswitch'
" t e s t _ m e r g e _ i d _ s c h e m a "
# AssertionError: assert 'unknown' == 'not_home'
" t e s t _ d e v i c e _ t r a c k e r _ n o t _ h o m e "
# Racy https://github.com/home-assistant/core/issues/41425
" t e s t _ c a c h e d _ e v e n t _ m e s s a g e "
] ;
preCheck = ''
# the tests require the existance of a media dir
mkdir /build/media
# - components' dependencies are not included, so they cannot be tested
# - test_merge_id_schema requires pyqwikswitch
# - test_loader.py tries to load not-packaged dependencies
# - test_notify pyotp doesn't like the short mock keys
# - unclear why test_merge fails: assert merge_log_err.call_count != 0
# - test_setup_safe_mode_if_no_frontend: requires dependencies for components we have not packaged
py . test \
- - ignore tests/components \
- - ignore tests/test_loader.py \
- - ignore tests/auth/mfa_modules/test_notify.py \
- k " n o t t e s t _ s e t u p _ s a f e _ m o d e _ i f _ n o _ f r o n t e n d a n d n o t t e s t _ m e r g e _ i d _ s c h e m a a n d n o t t e s t _ m e r g e "
# Some basic components should be tested however
py . test \
tests/components / { api , config , configurator , demo , discovery , frontend , group , history } \
tests/components / { homeassistant , http , logger , script , shell_command , system_log , websocket_api }
'' ;
makeWrapperArgs = lib . optional skipPip " - - a d d - f l a g s - - s k i p - p i p " ;