Skip to content

Commit 22d9fbe

Browse files
committed
cleanups
1 parent de65908 commit 22d9fbe

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

cwl_utils/file_formats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import List, Optional, Set, Union
88

9-
from rdflib import Graph, OWL, RDFS, URIRef
9+
from rdflib import OWL, RDFS, Graph, URIRef
1010
from schema_salad.exceptions import ValidationException
1111
from schema_salad.utils import aslist, json_dumps
1212

cwl_utils/graph_split.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from typing import IO, Any, MutableMapping, Set, Union, cast
1515

1616
from cwlformat.formatter import stringify_dict
17+
from ruamel.yaml.dumper import RoundTripDumper
1718
from ruamel.yaml.main import YAML, dump
1819
from ruamel.yaml.representer import RoundTripRepresenter
19-
from ruamel.yaml.dumper import RoundTripDumper
2020
from schema_salad.sourceline import SourceLine, add_lc_filename
2121

2222

cwl_utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
import urllib.parse
77
import urllib.request
88
from copy import deepcopy
9-
10-
from ruamel.yaml.main import YAML
11-
from ruamel.yaml.parser import ParserError
12-
from ruamel.yaml.scanner import ScannerError
139
from typing import (
1410
Any,
1511
Dict,
@@ -21,6 +17,10 @@
2117
Union,
2218
)
2319

20+
from ruamel.yaml.main import YAML
21+
from ruamel.yaml.parser import ParserError
22+
from ruamel.yaml.scanner import ScannerError
23+
2424
from cwl_utils.errors import MissingKeyField
2525
from cwl_utils.loghandler import _logger
2626

tests/test_format.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
"""Tests of cwl_utils.file_formats."""
2+
13
import xml.sax
2-
from typing import Any, Optional
4+
from typing import Optional
35

46
import requests
57
from pytest import raises
@@ -9,10 +11,11 @@
911
from schema_salad.fetcher import DefaultFetcher
1012

1113
from cwl_utils.file_formats import check_format
14+
from cwl_utils.types import CWLObjectType
1215

1316

14-
def _create_file(format_: Optional[str] = None) -> Any:
15-
obj = {
17+
def _create_file(format_: Optional[str] = None) -> CWLObjectType:
18+
obj: CWLObjectType = {
1619
"class": "File",
1720
"basename": "example.txt",
1821
"size": 23,
@@ -46,7 +49,17 @@ def test_check_format() -> None:
4649
)
4750

4851

52+
def test_check_format_subformat() -> None:
53+
"""Test of check_format with a subformat."""
54+
check_format(
55+
actual_file=_create_file(format_="http://edamontology.org/format_1929"),
56+
input_formats="http://edamontology.org/format_2330",
57+
ontology=_load_format("http://edamontology.org/EDAM.owl"),
58+
)
59+
60+
4961
def test_check_format_no_format() -> None:
62+
"""Confirm that a missing format produces the expected exception."""
5063
with raises(ValidationException, match=r"File has no 'format' defined: .*"):
5164
check_format(
5265
actual_file=_create_file(),
@@ -56,6 +69,7 @@ def test_check_format_no_format() -> None:
5669

5770

5871
def test_check_format_no_input_formats() -> None:
72+
"""Unknown test."""
5973
with raises(ValidationException, match=r"File has an incompatible format: .*"):
6074
check_format(
6175
actual_file=_create_file(format_="http://edamontology.org/format_2330"),
@@ -65,6 +79,7 @@ def test_check_format_no_input_formats() -> None:
6579

6680

6781
def test_check_format_no_ontology() -> None:
82+
"""Confirm that precisely matching formats without an ontology still match."""
6883
check_format(
6984
actual_file=_create_file(format_="http://edamontology.org/format_2330"),
7085
input_formats="http://edamontology.org/format_2330",

0 commit comments

Comments
 (0)