@@ -403,8 +403,9 @@ async def test_api_store_addons_addon_availability_success(
403403 assert resp .status == 200
404404
405405
406+ @pytest .mark .parametrize ("supported_architectures" , [["i386" ], ["i386" , "aarch64" ]])
406407async def test_api_store_addons_addon_availability_arch_not_supported (
407- api_client : TestClient , coresys : CoreSys
408+ api_client : TestClient , coresys : CoreSys , supported_architectures : list [ str ]
408409):
409410 """Test /store/addons/{addon}/availability REST API - architecture not supported."""
410411 # Create an addon with unsupported architecture
@@ -414,8 +415,8 @@ async def test_api_store_addons_addon_availability_arch_not_supported(
414415 # Set addon config with unsupported architecture
415416 addon_config = {
416417 "advanced" : False ,
417- "arch" : [ "i386" ], # Not supported on current system
418- "slug" : "test_arch " ,
418+ "arch" : supported_architectures ,
419+ "slug" : "test_arch_addon " ,
419420 "description" : "Test arch add-on" ,
420421 "name" : "Test Arch Add-on" ,
421422 "repository" : "test" ,
@@ -429,10 +430,23 @@ async def test_api_store_addons_addon_availability_arch_not_supported(
429430 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
430431 assert resp .status == 400
431432 result = await resp .json ()
432- assert "not supported on this platform" in result ["message" ]
433+ assert result ["error_key" ] == "addon_not_supported_architecture_error"
434+ assert (
435+ result ["message_template" ]
436+ == "Add-on {slug} not supported on this platform, supported architectures: {architectures}"
437+ )
438+ assert result ["extra_fields" ] == {
439+ "slug" : "test_arch_addon" ,
440+ "architectures" : ", " .join (supported_architectures ),
441+ }
442+ assert result ["message" ] == result ["message_template" ].format (
443+ ** result ["extra_fields" ]
444+ )
433445
434446
435- @pytest .mark .parametrize ("supported_machines" , [["odroid-n2" ], ["!qemux86-64" ]])
447+ @pytest .mark .parametrize (
448+ "supported_machines" , [["odroid-n2" ], ["!qemux86-64" ], ["a" , "b" ]]
449+ )
436450async def test_api_store_addons_addon_availability_machine_not_supported (
437451 api_client : TestClient , coresys : CoreSys , supported_machines : list [str ]
438452):
@@ -446,7 +460,7 @@ async def test_api_store_addons_addon_availability_machine_not_supported(
446460 "advanced" : False ,
447461 "arch" : ["amd64" ],
448462 "machine" : supported_machines ,
449- "slug" : "test_machine " ,
463+ "slug" : "test_machine_addon " ,
450464 "description" : "Test machine add-on" ,
451465 "name" : "Test Machine Add-on" ,
452466 "repository" : "test" ,
@@ -460,7 +474,18 @@ async def test_api_store_addons_addon_availability_machine_not_supported(
460474 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
461475 assert resp .status == 400
462476 result = await resp .json ()
463- assert "not supported on this machine" in result ["message" ]
477+ assert result ["error_key" ] == "addon_not_supported_machine_type_error"
478+ assert (
479+ result ["message_template" ]
480+ == "Add-on {slug} not supported on this machine, supported machine types: {machine_types}"
481+ )
482+ assert result ["extra_fields" ] == {
483+ "slug" : "test_machine_addon" ,
484+ "machine_types" : ", " .join (supported_machines ),
485+ }
486+ assert result ["message" ] == result ["message_template" ].format (
487+ ** result ["extra_fields" ]
488+ )
464489
465490
466491async def test_api_store_addons_addon_availability_homeassistant_version_too_old (
@@ -476,7 +501,7 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old
476501 "advanced" : False ,
477502 "arch" : ["amd64" ],
478503 "homeassistant" : "2023.1.1" , # Requires newer version than current
479- "slug" : "test_version " ,
504+ "slug" : "test_version_addon " ,
480505 "description" : "Test version add-on" ,
481506 "name" : "Test Version Add-on" ,
482507 "repository" : "test" ,
@@ -494,8 +519,17 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old
494519 resp = await api_client .get (f"/store/addons/{ addon_obj .slug } /availability" )
495520 assert resp .status == 400
496521 result = await resp .json ()
522+ assert result ["error_key" ] == "addon_not_supported_home_assistant_version_error"
497523 assert (
498- "requires Home Assistant version 2023.1.1 or greater" in result ["message" ]
524+ result ["message_template" ]
525+ == "Add-on {slug} not supported on this system, requires Home Assistant version {version} or greater"
526+ )
527+ assert result ["extra_fields" ] == {
528+ "slug" : "test_version_addon" ,
529+ "version" : "2023.1.1" ,
530+ }
531+ assert result ["message" ] == result ["message_template" ].format (
532+ ** result ["extra_fields" ]
499533 )
500534
501535
0 commit comments