Working Yandex Disk integration for loading files. Tests for local and Yandex

This commit is contained in:
2026-02-10 20:42:07 +03:00
parent 63c3e2c5c7
commit 06a3155b6b
8 changed files with 222 additions and 12 deletions

View File

@@ -0,0 +1,40 @@
import os
import unittest
from pathlib import Path
import requests
from loguru import logger
from dotenv import load_dotenv
from helpers import YandexDiskAdaptiveCollection
load_dotenv(dotenv_path=Path(__file__).resolve().parent.parent / ".env.test")
class TestYandexDiskAdaptiveCollection(unittest.TestCase):
def test_constructor_requires_token(self):
with self.assertRaises(ValueError):
YandexDiskAdaptiveCollection(token="", base_dir="Общая/Информация")
def test_iterate_logs_found_files_for_shared_folder(self):
token = os.getenv("YADISK_TOKEN")
if not token:
self.skipTest("YADISK_TOKEN is not configured")
collection = YandexDiskAdaptiveCollection(
token=token,
base_dir="Общая/Информация",
)
try:
files = list(collection.iterate(recursive=True))
except requests.RequestException as exc:
self.skipTest(f"Yandex Disk request failed and needs manual verification: {exc}")
for item in files:
logger.info(f"Yandex file found during test iteration: {item.local_path}")
self.assertIsInstance(files, list)
if __name__ == "__main__":
unittest.main()