-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathtest_directory.py
31 lines (25 loc) · 1012 Bytes
/
test_directory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.
#
import pytest
from connectors.sources.directory import DEFAULT_DIR, DirectoryDataSource
from tests.sources.support import assert_basics, create_source
@pytest.mark.asyncio
async def test_basics():
await assert_basics(DirectoryDataSource, "directory", DEFAULT_DIR)
@pytest.mark.asyncio
async def test_get_docs(catch_stdout):
async with create_source(DirectoryDataSource) as source:
num = 0
async for doc, dl in source.get_docs():
num += 1
if doc["path"].endswith("__init__.py"):
continue
data = await dl(doit=True, timestamp="xx")
if data is not None:
assert len(data["_attachment"]) > 0
if num > 100:
break
assert num > 3