@@ -42,6 +42,51 @@ def get_schema(server):
42
42
schema = schemathesis .from_pytest_fixture ("get_schema" )
43
43
44
44
45
+ @schemathesis .hook
46
+ def before_generate_case (context : schemathesis .hooks .HookContext , strategy ):
47
+ op = context .operation
48
+ assert op is not None
49
+
50
+ def no_file_type (case : schemathesis .models .Case ):
51
+ """
52
+ This filter skips test cases for the `POST /tokenize` endpoint where the
53
+ HTTP request body uses `"type": "file"` in any message's content.
54
+ We expect these cases to fail because that type isn't implemented here
55
+ https://github.com/vllm-project/vllm/blob/0b34593017953051b3225b1483ce0f4670e3eb0e/vllm/entrypoints/chat_utils.py#L1038-L1095
56
+
57
+ Example test cases that are skipped:
58
+ curl -X POST -H 'Content-Type: application/json' \
59
+ -d '{"messages": [{"role": "assistant"}, {"content": [{"file": {}, "type": "file"}], "role": "user"}]}' \
60
+ http://localhost:8000/tokenize
61
+
62
+ curl -X POST -H 'Content-Type: application/json' \
63
+ -d '{"messages": [{"content": [{"file": {}, "type": "file"}], "role": "user"}]}' \
64
+ http://localhost:8000/tokenize
65
+ """ # noqa: E501
66
+ if op .method .lower () != "post" or op .path != "/tokenize" :
67
+ return True
68
+
69
+ if case .body and isinstance (case .body , dict ):
70
+ if "messages" not in case .body :
71
+ return True
72
+
73
+ messages = case .body .get ("messages" , [])
74
+ if not isinstance (messages , list ) or len (messages ) == 0 :
75
+ return True
76
+
77
+ for message in messages :
78
+ if not isinstance (message , dict ):
79
+ continue
80
+ content = message .get ("content" , [])
81
+ if not isinstance (content , list ) or len (content ) == 0 :
82
+ continue
83
+ if any (item .get ("type" ) == "file" for item in content ):
84
+ return False
85
+ return True
86
+
87
+ return strategy .filter (no_file_type )
88
+
89
+
45
90
@schema .parametrize ()
46
91
@schema .override (headers = {"Content-Type" : "application/json" })
47
92
def test_openapi_stateless (case : schemathesis .Case ):
0 commit comments