@@ -43,10 +43,48 @@ def test_all_ai_horde_api_data_objects_imported() -> None:
4343@pytest .mark .object_verify
4444def test_all_ai_horde_api_models_defined () -> None :
4545 import horde_sdk .ai_horde_api .apimodels
46- from horde_sdk .meta import all_undefined_classes
46+ from horde_sdk .meta import all_undefined_classes , all_undefined_classes_for_endpoints
4747
4848 undefined_classes = all_undefined_classes (horde_sdk .ai_horde_api .apimodels )
4949
50+ # all_undefined_classes_for_endpoints handles the ones directly referenced by endpoints, so we remove them
51+ undefined_classes_for_endpoints = all_undefined_classes_for_endpoints (horde_sdk .ai_horde_api .apimodels )
52+ for key in undefined_classes_for_endpoints :
53+ if key in undefined_classes :
54+ undefined_classes .remove (key )
55+
56+ assert (
57+ "GenerationInputStable" not in undefined_classes
58+ ), "A model which is known to be defined in the SDK was not found. Something critically bad has happened."
59+
60+ # Pretty print the undefined classes sorted by dict values, NOT by keys
61+ import json
62+
63+ error_responses = {
64+ "RequestError" ,
65+ "RequestValidationError" ,
66+ }
67+
68+ for error_response in error_responses :
69+ if error_response in undefined_classes :
70+ print (f"Warning: { error_response } is an error response which may not be handled." )
71+ undefined_classes .remove (error_response )
72+
73+ undefined_classes_sorted = sorted (undefined_classes )
74+ print (json .dumps (undefined_classes_sorted , indent = 4 ))
75+
76+ assert not undefined_classes , (
77+ "The following models are defined in the API but not in the SDK: " f"{ undefined_classes } "
78+ )
79+
80+
81+ @pytest .mark .object_verify
82+ def test_all_ai_horde_api_models_defined_for_endpoints () -> None :
83+ import horde_sdk .ai_horde_api .apimodels
84+ from horde_sdk .meta import all_undefined_classes_for_endpoints
85+
86+ undefined_classes = all_undefined_classes_for_endpoints (horde_sdk .ai_horde_api .apimodels )
87+
5088 assert (
5189 "GenerationInputStable" not in undefined_classes
5290 ), "A model which is known to be defined in the SDK was not found. Something critically bad has happened."
@@ -86,10 +124,19 @@ def test_all_ai_horde_endpoints_known() -> None:
86124# @pytest.mark.skip(reason="This test is not yet enforced.")
87125@pytest .mark .object_verify
88126def test_all_ai_horde_endpoints_addressed () -> None :
127+ from horde_sdk .ai_horde_api .endpoints import get_admin_only_endpoints , get_deprecated_endpoints
89128 from horde_sdk .meta import all_unaddressed_endpoints_ai_horde
90129
91130 unaddressed_endpoints = all_unaddressed_endpoints_ai_horde ()
92131
132+ all_ignored_endpoints = get_admin_only_endpoints () | get_deprecated_endpoints ()
133+
134+ unaddressed_endpoints -= all_ignored_endpoints
135+
136+ print ()
137+ for unaddressed_endpoint in unaddressed_endpoints :
138+ print (f"Unaddressed path: { unaddressed_endpoint } ." )
139+
93140 assert not unaddressed_endpoints , (
94141 "The following endpoints are defined in the API but not in the SDK: " f"{ unaddressed_endpoints } "
95142 )
0 commit comments