@@ -505,8 +505,9 @@ async def test_api_store_addons_addon_availability_success(
505505 assert resp .status == 200
506506
507507
508+ @pytest .mark .parametrize ("supported_architectures" , [["i386" ], ["i386" , "aarch64" ]])
508509async def test_api_store_addons_addon_availability_arch_not_supported (
509- api_client : TestClient , coresys : CoreSys
510+ api_client : TestClient , coresys : CoreSys , supported_architectures : list [ str ]
510511):
511512 """Test /store/addons/{addon}/availability REST API - architecture not supported."""
512513 # Create an addon with unsupported architecture
@@ -516,8 +517,8 @@ async def test_api_store_addons_addon_availability_arch_not_supported(
516517 # Set addon config with unsupported architecture
517518 addon_config = {
518519 "advanced" : False ,
519- "arch" : [ "i386" ], # Not supported on current system
520- "slug" : "test_arch " ,
520+ "arch" : supported_architectures ,
521+ "slug" : "test_arch_addon " ,
521522 "description" : "Test arch add-on" ,
522523 "name" : "Test Arch Add-on" ,
523524 "repository" : "test" ,
@@ -531,10 +532,23 @@ async def test_api_store_addons_addon_availability_arch_not_supported(
531532 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
532533 assert resp .status == 400
533534 result = await resp .json ()
534- assert "not supported on this platform" in result ["message" ]
535+ assert result ["error_key" ] == "addon_not_supported_architecture_error"
536+ assert (
537+ result ["message_template" ]
538+ == "Add-on {slug} not supported on this platform, supported architectures: {architectures}"
539+ )
540+ assert result ["extra_fields" ] == {
541+ "slug" : "test_arch_addon" ,
542+ "architectures" : ", " .join (supported_architectures ),
543+ }
544+ assert result ["message" ] == result ["message_template" ].format (
545+ ** result ["extra_fields" ]
546+ )
535547
536548
537- @pytest .mark .parametrize ("supported_machines" , [["odroid-n2" ], ["!qemux86-64" ]])
549+ @pytest .mark .parametrize (
550+ "supported_machines" , [["odroid-n2" ], ["!qemux86-64" ], ["a" , "b" ]]
551+ )
538552async def test_api_store_addons_addon_availability_machine_not_supported (
539553 api_client : TestClient , coresys : CoreSys , supported_machines : list [str ]
540554):
@@ -548,7 +562,7 @@ async def test_api_store_addons_addon_availability_machine_not_supported(
548562 "advanced" : False ,
549563 "arch" : ["amd64" ],
550564 "machine" : supported_machines ,
551- "slug" : "test_machine " ,
565+ "slug" : "test_machine_addon " ,
552566 "description" : "Test machine add-on" ,
553567 "name" : "Test Machine Add-on" ,
554568 "repository" : "test" ,
@@ -562,7 +576,18 @@ async def test_api_store_addons_addon_availability_machine_not_supported(
562576 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
563577 assert resp .status == 400
564578 result = await resp .json ()
565- assert "not supported on this machine" in result ["message" ]
579+ assert result ["error_key" ] == "addon_not_supported_machine_type_error"
580+ assert (
581+ result ["message_template" ]
582+ == "Add-on {slug} not supported on this machine, supported machine types: {machine_types}"
583+ )
584+ assert result ["extra_fields" ] == {
585+ "slug" : "test_machine_addon" ,
586+ "machine_types" : ", " .join (supported_machines ),
587+ }
588+ assert result ["message" ] == result ["message_template" ].format (
589+ ** result ["extra_fields" ]
590+ )
566591
567592
568593async def test_api_store_addons_addon_availability_homeassistant_version_too_old (
@@ -578,7 +603,7 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old
578603 "advanced" : False ,
579604 "arch" : ["amd64" ],
580605 "homeassistant" : "2023.1.1" , # Requires newer version than current
581- "slug" : "test_version " ,
606+ "slug" : "test_version_addon " ,
582607 "description" : "Test version add-on" ,
583608 "name" : "Test Version Add-on" ,
584609 "repository" : "test" ,
@@ -596,8 +621,17 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old
596621 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
597622 assert resp .status == 400
598623 result = await resp .json ()
624+ assert result ["error_key" ] == "addon_not_supported_home_assistant_version_error"
599625 assert (
600- "requires Home Assistant version 2023.1.1 or greater" in result ["message" ]
626+ result ["message_template" ]
627+ == "Add-on {slug} not supported on this system, requires Home Assistant version {version} or greater"
628+ )
629+ assert result ["extra_fields" ] == {
630+ "slug" : "test_version_addon" ,
631+ "version" : "2023.1.1" ,
632+ }
633+ assert result ["message" ] == result ["message_template" ].format (
634+ ** result ["extra_fields" ]
601635 )
602636
603637
0 commit comments