Working Yandex Disk integration for loading files. Tests for local and Yandex
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user