Files
rag-solution/services/rag/langchain/test/test_yandex_disk_adaptive_collection.py

41 lines
1.2 KiB
Python
Raw Normal View History

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()