fix: stream direct site videos
This commit is contained in:
@@ -1,4 +1,28 @@
|
||||
from vk_parser_app.workers.vk_storage_uploader import video_provider
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from vk_parser_app.workers.vk_storage_uploader import TelegramStorageUploader, video_provider
|
||||
|
||||
|
||||
class FakeContent:
|
||||
async def iter_chunked(self, _size):
|
||||
yield b"video"
|
||||
|
||||
|
||||
class FakeResponse:
|
||||
status = 200
|
||||
content = FakeContent()
|
||||
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_args):
|
||||
return None
|
||||
|
||||
|
||||
class FakeSession:
|
||||
def get(self, *_args, **_kwargs):
|
||||
return FakeResponse()
|
||||
|
||||
|
||||
def test_video_provider() -> None:
|
||||
@@ -9,5 +33,14 @@ def test_video_provider() -> None:
|
||||
assert video_provider("http://127.0.0.1/video.mp4") is None
|
||||
|
||||
|
||||
async def test_http_video_download() -> None:
|
||||
path = "/tmp/vkparser_tg_media_http_test.mp4"
|
||||
result = await TelegramStorageUploader().download_http_video(FakeSession(), "https://example.test/a.mp4", path)
|
||||
assert result["size_bytes"] == 5
|
||||
assert Path(path).read_bytes() == b"video"
|
||||
Path(path).unlink()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_video_provider()
|
||||
asyncio.run(test_http_video_download())
|
||||
|
||||
Reference in New Issue
Block a user