@@ -272,20 +272,23 @@ async def get_json():
272
272
273
273
274
274
class TestCopilotDetector :
275
- def test_successful_detection (self , mock_request ):
275
+ @pytest .mark .asyncio
276
+ async def test_successful_detection (self , mock_request ):
276
277
detector = CopilotDetector ()
277
278
mock_request .headers = Headers ({"user-agent" : "Copilot" })
278
- assert detector .detect (mock_request ) is True
279
+ assert await detector .detect (mock_request ) is True
279
280
assert detector .client_name == ClientType .COPILOT
280
281
281
- def test_failed_detection (self , mock_request ):
282
+ @pytest .mark .asyncio
283
+ async def test_failed_detection (self , mock_request ):
282
284
detector = CopilotDetector ()
283
285
mock_request .headers = Headers ({"user-agent" : "Different Client" })
284
- assert detector .detect (mock_request ) is False
286
+ assert await detector .detect (mock_request ) is False
285
287
286
- def test_missing_user_agent (self , mock_request ):
288
+ @pytest .mark .asyncio
289
+ async def test_missing_user_agent (self , mock_request ):
287
290
detector = CopilotDetector ()
288
- assert detector .detect (mock_request ) is False
291
+ assert await detector .detect (mock_request ) is False
289
292
290
293
291
294
class TestDetectClient :
@@ -353,3 +356,15 @@ async def test_endpoint(request: Request):
353
356
354
357
result = await test_endpoint (mock_request )
355
358
assert result == ClientType .KODU
359
+
360
+ @pytest .mark .asyncio
361
+ async def test_copilot_detection_in_detect_client (self , mock_request ):
362
+ detect_client = DetectClient ()
363
+ mock_request .headers = Headers ({"user-agent" : "Copilot" })
364
+
365
+ @detect_client
366
+ async def test_endpoint (request : Request ):
367
+ return request .state .detected_client
368
+
369
+ result = await test_endpoint (mock_request )
370
+ assert result == ClientType .COPILOT
0 commit comments