|
1 | 1 | import jsonschema |
2 | 2 |
|
3 | 3 | import pytest |
| 4 | +from apex_algorithm_qa_tools.common import get_project_root |
| 5 | +from pathlib import Path |
4 | 6 | from apex_algorithm_qa_tools.records import ( |
5 | 7 | get_service_ogc_records, |
6 | 8 | get_service_ogc_record_schema, |
7 | 9 | get_platform_ogc_records, |
8 | 10 | get_platform_ogc_record_schema, |
| 11 | + get_provider_ogc_records, |
| 12 | + get_provider_ogc_record_schema, |
9 | 13 | ) |
10 | 14 |
|
11 | 15 |
|
@@ -44,3 +48,26 @@ def test_service_record_validation(record): |
44 | 48 | ) |
45 | 49 | def test_platform_record_validation(record): |
46 | 50 | jsonschema.validate(instance=record, schema=get_platform_ogc_record_schema()) |
| 51 | + |
| 52 | + |
| 53 | +def test_algorithm_provider_records_(): |
| 54 | + # Test that there is at least one provider record based on the folder structure in the algorithm_repo directory. |
| 55 | + # For each subfolder in the `algorithm_catalog` folder, there should be exactly one provider record with a matching `record.json`. |
| 56 | + algorithm_catalog_dir: Path = get_project_root() / "algorithm_catalog" |
| 57 | + subdirs = [p.name for p in algorithm_catalog_dir.iterdir() if p.is_dir()] |
| 58 | + assert len(subdirs) > 0, "No subfolders found under algorithm_catalog" |
| 59 | + |
| 60 | + for subdir in subdirs: |
| 61 | + assert (algorithm_catalog_dir / subdir / "record.json").exists(), f"Missing record.json for provider '{subdir}'" |
| 62 | + |
| 63 | + |
| 64 | +@pytest.mark.parametrize( |
| 65 | + "record", |
| 66 | + [ |
| 67 | + # Use scenario id as parameterization id to give nicer test names. |
| 68 | + pytest.param(record, id=record["id"]) |
| 69 | + for record in get_provider_ogc_records() |
| 70 | + ], |
| 71 | +) |
| 72 | +def test_provider_record_validation(record): |
| 73 | + jsonschema.validate(instance=record, schema=get_provider_ogc_record_schema()) |
0 commit comments