1414OVERRIDES_PATH = Path ("openapi/sdk_overrides.yaml" )
1515
1616
17+ def count_operations (spec : dict ) -> int :
18+ return sum (
19+ 1
20+ for path_item in spec .get ("paths" , {}).values ()
21+ for method in path_item
22+ if not method .startswith ("x-" )
23+ )
24+
25+
26+ def collect_resource_namespaces (spec : dict ) -> set [str ]:
27+ return {
28+ operation ["x-sdk-resource" ]
29+ for path_item in spec .get ("paths" , {}).values ()
30+ for method , operation in path_item .items ()
31+ if not method .startswith ("x-" )
32+ }
33+
34+
1735def test_normalize_spec_removes_token_and_adds_security_scheme ():
1836 normalized = normalize_spec (
1937 load_json (RAW_SPEC_PATH ), load_overrides (OVERRIDES_PATH )
@@ -33,10 +51,14 @@ def test_collect_resources_matches_expected_counts():
3351 load_json (RAW_SPEC_PATH ), load_overrides (OVERRIDES_PATH )
3452 )
3553 resources = collect_resources (normalized )
54+ expected_namespaces = collect_resource_namespaces (normalized )
3655
37- assert len (resources ) == 25
38- assert sum (len (resource .operations ) for resource in resources ) == 201
3956 namespace_set = {resource .namespace for resource in resources }
57+ assert len (resources ) == len (expected_namespaces )
58+ assert sum (len (resource .operations ) for resource in resources ) == count_operations (
59+ normalized
60+ )
61+ assert namespace_set == expected_namespaces
4062 assert {"douyin" , "douyin_xingtu" , "tiktok_shop" , "xiaohongshu_pgy" }.issubset (
4163 namespace_set
4264 )
0 commit comments