File: test_schema.py

package info (click to toggle)
python-schema-salad 8.4.20230213094415-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,440 kB
  • sloc: python: 14,250; cs: 1,771; java: 1,243; makefile: 189; xml: 184; sh: 108; javascript: 46
file content (31 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download
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
from pathlib import Path
from typing import Any, Dict, List, cast

from schema_salad import schema

from .util import get_data_uri

cwl_file_uri = get_data_uri("tests/test_schema/CommonWorkflowLanguage.yml")


def test_extend_and_specialize_enums(tmp_path: Path) -> None:
    document_loader, _, _, metaschema_loader = schema.load_schema(cwl_file_uri)
    schema_raw_doc = metaschema_loader.fetch(cwl_file_uri)
    schema_doc, _ = metaschema_loader.resolve_all(schema_raw_doc, cwl_file_uri)

    j = schema.extend_and_specialize(cast(List[Dict[str, Any]], schema_doc), document_loader)
    CWLType = next((x for x in j if x["name"] == "https://w3id.org/cwl/cwl#CWLType"), None)
    assert CWLType is not None
    symbols = [
        "https://w3id.org/cwl/salad#null",
        "http://www.w3.org/2001/XMLSchema#boolean",
        "http://www.w3.org/2001/XMLSchema#int",
        "http://www.w3.org/2001/XMLSchema#long",
        "http://www.w3.org/2001/XMLSchema#float",
        "http://www.w3.org/2001/XMLSchema#double",
        "http://www.w3.org/2001/XMLSchema#string",
        "https://w3id.org/cwl/cwl#File",
        "https://w3id.org/cwl/cwl#Directory",
    ]
    for symbol in symbols:
        assert symbol in CWLType["symbols"]