-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
49 lines (37 loc) · 1.51 KB
/
conftest.py
File metadata and controls
49 lines (37 loc) · 1.51 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Pytest configuration and fixtures."""
import pytest
from pathlib import Path
from linkml_reference_validator.models import ReferenceValidationConfig
from linkml_reference_validator.validation.supporting_text_validator import (
SupportingTextValidator,
)
from linkml_reference_validator.etl.reference_fetcher import ReferenceFetcher
@pytest.fixture
def fixtures_dir():
"""Get the test fixtures directory."""
return Path(__file__).parent / "fixtures"
@pytest.fixture
def test_config(tmp_path, fixtures_dir):
"""Create a test configuration that uses fixtures directory as cache.
This allows tests to use real cached references instead of mocks.
"""
# Copy fixtures to temp cache directory
cache_dir = tmp_path / "cache"
cache_dir.mkdir()
# Copy test fixtures to cache (both .txt and .md formats)
for fixture_file in fixtures_dir.glob("*.txt"):
(cache_dir / fixture_file.name).write_text(fixture_file.read_text())
for fixture_file in fixtures_dir.glob("*.md"):
(cache_dir / fixture_file.name).write_text(fixture_file.read_text())
return ReferenceValidationConfig(
cache_dir=cache_dir,
rate_limit_delay=0.0, # No delay for tests
)
@pytest.fixture
def validator_with_fixtures(test_config):
"""Create a validator with real cached references."""
return SupportingTextValidator(test_config)
@pytest.fixture
def fetcher_with_fixtures(test_config):
"""Create a fetcher with real cached references."""
return ReferenceFetcher(test_config)