|
| 1 | +import re |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from semsql.builder import builder |
| 6 | +from semsql.builder.registry import path_to_ontology_registry |
| 7 | + |
| 8 | + |
| 9 | +@pytest.fixture(scope="module") |
| 10 | +def registry_makefile() -> str: |
| 11 | + return builder.compile_registry(str(path_to_ontology_registry())) |
| 12 | + |
| 13 | + |
| 14 | +@pytest.mark.parametrize( |
| 15 | + ("ontology_id", "url"), |
| 16 | + [ |
| 17 | + ( |
| 18 | + "cepo", |
| 19 | + "https://raw.githubusercontent.com/OpenEnergyPlatform/ClimateEnergyPolicyOntology/production/src/ontology/cepo.owl", |
| 20 | + ), |
| 21 | + ( |
| 22 | + "oto", |
| 23 | + "https://raw.githubusercontent.com/OpenEnergyPlatform/OpenTransportOntology/production/src/ontology/oto.ttl", |
| 24 | + ), |
| 25 | + ], |
| 26 | +) |
| 27 | +def test_enero_download_rules_present(registry_makefile: str, ontology_id: str, url: str): |
| 28 | + assert f"download/{ontology_id}.owl: STAMP" in registry_makefile |
| 29 | + assert f"curl -L -s {url} > $@.tmp" in registry_makefile |
| 30 | + |
| 31 | + |
| 32 | +@pytest.mark.parametrize( |
| 33 | + ("ontology_id", "command"), |
| 34 | + [ |
| 35 | + ("cepo", r"robot merge -i \$< -o \$@"), |
| 36 | + ( |
| 37 | + "oto", |
| 38 | + r"perl -0pe 's@http://w3id.org/oto/develop/oto-shared.ttl@https://raw.githubusercontent.com/OpenEnergyPlatform/OpenTransportOntology/production/src/ontology/edits/oto-shared.ttl@g' \$< > \$@\.tmp\.ttl && robot merge -i \$@\.tmp\.ttl -o \$@ && rm \$@\.tmp\.ttl", |
| 39 | + ), |
| 40 | + ], |
| 41 | +) |
| 42 | +def test_enero_build_rules_present( |
| 43 | + registry_makefile: str, ontology_id: str, command: str |
| 44 | +): |
| 45 | + pattern = rf"db/{ontology_id}\.owl: download/{ontology_id}\.owl\n\t{command}" |
| 46 | + assert re.search(pattern, registry_makefile) |
0 commit comments