-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (44 loc) · 1.32 KB
/
conftest.py
File metadata and controls
52 lines (44 loc) · 1.32 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
50
51
52
# tests/conftest.py
import os
from pathlib import Path
from dotenv import load_dotenv
import pytest
from rdflib import Graph
# --- Environment Setup ---
env_path = Path(__file__).resolve().parents[1] / ".env"
load_dotenv(env_path)
from strings2things.app.config import Settings
from strings2things.app.core.ontology_manager import OntologyManager
from strings2things.app.core.rdf_transformer import RDFTransformer
settings = Settings() # now environment variables are loaded
# --- Fixtures ---
@pytest.fixture
def ontology_manager():
"""
Returns an OntologyManager with predicate-specific label maps built
from examples/ontologies/test_ont.ttl
"""
om = OntologyManager()
om.graph.parse("examples/ontologies/test_ont.ttl", format="turtle")
om._build_predicate_label_map()
return om
@pytest.fixture
def input_graph():
"""
Returns the input RDF graph from examples/data/test_data.ttl
"""
g = Graph()
g.parse("examples/data/test_data.ttl", format="turtle")
return g
@pytest.fixture
def simple_label_map():
"""
Returns a small label map for RDFTransformer unit tests
"""
from rdflib import Namespace
EX = Namespace("http://example.org/ontology#")
return {
"geology": str(EX.Geology),
"biology": str(EX.Biology),
"physics": str(EX.Physics),
}