77from pymax .exceptions import UploadError
88from pymax .files import File , Photo , Video
99from pymax .protocol import Opcode
10+ from pymax .types .domain .attachments import VideoRequest
1011from tests .conftest import FakeApp , frame , message_payload
1112
1213
@@ -372,7 +373,15 @@ async def test_reaction_methods_parse_optional_reaction_info() -> None:
372373async def test_get_video_and_file_by_id_parse_request_models () -> None :
373374 app = FakeApp (
374375 [
375- frame ({"cache" : True , "dynamicUrl" : "https://video.test" }),
376+ frame (
377+ {
378+ "cache" : True ,
379+ "FAILOVER_HOSTS" : ["maxvd759.okcdn.ru" ],
380+ "MP4_480" : "https://video.test/480" ,
381+ "EXTERNAL" : "https://m.ok.ru/video/1" ,
382+ "MP4_720" : "https://video.test/720" ,
383+ }
384+ ),
376385 frame ({"unsafe" : False , "url" : "https://file.test" }),
377386 ]
378387 )
@@ -381,7 +390,8 @@ async def test_get_video_and_file_by_id_parse_request_models() -> None:
381390 file = await app .api .messages .get_file_by_id (100 , "10" , 30 )
382391
383392 assert video is not None
384- assert video .url == "https://video.test"
393+ assert video .url == "https://video.test/720"
394+ assert video .external == "https://m.ok.ru/video/1"
385395 assert file is not None
386396 assert file .url == "https://file.test"
387397 assert [call .opcode for call in app .calls ] == [
@@ -400,6 +410,19 @@ async def test_get_video_and_file_by_id_parse_request_models() -> None:
400410 }
401411
402412
413+ def test_video_request_supports_legacy_and_external_only_payloads () -> None :
414+ legacy = VideoRequest .model_validate (
415+ {"cache" : True , "dynamicUrl" : "https://video.test/legacy" }
416+ )
417+ external = VideoRequest .model_validate (
418+ {"cache" : True , "EXTERNAL" : "https://m.ok.ru/video/1" }
419+ )
420+
421+ assert legacy .url == "https://video.test/legacy"
422+ assert external .url is None
423+ assert external .external == "https://m.ok.ru/video/1"
424+
425+
403426def test_next_cid_is_monotonic_when_clock_does_not_move (
404427 monkeypatch : pytest .MonkeyPatch ,
405428) -> None :
0 commit comments