|
21 | 21 | from .util import get_data, needs_docker |
22 | 22 |
|
23 | 23 |
|
24 | | -def test_pack() -> None: |
25 | | - loadingContext, workflowobj, uri = fetch_document(get_data("tests/wf/revsort.cwl")) |
26 | | - yaml = YAML(typ="safe", pure=True) |
27 | | - |
28 | | - with open(get_data("tests/wf/expect_packed.cwl")) as packed_file: |
29 | | - expect_packed = yaml.load(packed_file) |
30 | | - |
31 | | - packed = cwltool.pack.pack(loadingContext, uri) |
32 | | - adjustFileObjs( |
33 | | - packed, partial(make_relative, os.path.abspath(get_data("tests/wf"))) |
34 | | - ) |
35 | | - adjustDirObjs(packed, partial(make_relative, os.path.abspath(get_data("tests/wf")))) |
36 | | - |
37 | | - assert "$schemas" in packed |
38 | | - packed_schemas = packed["$schemas"] |
39 | | - assert isinstance(packed_schemas, Sized) |
40 | | - assert len(packed_schemas) == len(expect_packed["$schemas"]) |
41 | | - del packed["$schemas"] |
42 | | - del expect_packed["$schemas"] |
43 | | - |
44 | | - assert packed == expect_packed |
45 | | - |
46 | | - |
47 | | -def test_pack_input_named_name() -> None: |
48 | | - loadingContext, workflowobj, uri = fetch_document( |
49 | | - get_data("tests/wf/trick_revsort.cwl") |
50 | | - ) |
| 24 | +@pytest.mark.parametrize( |
| 25 | + "unpacked,expected", |
| 26 | + [ |
| 27 | + ("tests/wf/revsort.cwl", "tests/wf/expect_packed.cwl"), |
| 28 | + ( |
| 29 | + "tests/wf/operation/operation-single.cwl", |
| 30 | + "tests/wf/operation/expect_operation-single_packed.cwl", |
| 31 | + ), |
| 32 | + ("tests/wf/trick_revsort.cwl", "tests/wf/expect_trick_packed.cwl"), |
| 33 | + ], |
| 34 | +) |
| 35 | +def test_packing(unpacked: str, expected: str) -> None: |
| 36 | + """Compare expected version reality with various workflows and --pack.""" |
| 37 | + loadingContext, workflowobj, uri = fetch_document(get_data(unpacked)) |
51 | 38 | loadingContext.do_update = False |
52 | 39 | loadingContext, uri = resolve_and_validate_document( |
53 | 40 | loadingContext, workflowobj, uri |
54 | 41 | ) |
55 | | - loader = loadingContext.loader |
56 | | - assert loader |
57 | | - loader.resolve_ref(uri)[0] |
58 | | - |
59 | | - yaml = YAML() |
60 | | - with open(get_data("tests/wf/expect_trick_packed.cwl")) as packed_file: |
61 | | - expect_packed = yaml.load(packed_file) |
62 | 42 |
|
63 | 43 | packed = cwltool.pack.pack(loadingContext, uri) |
64 | | - adjustFileObjs( |
65 | | - packed, partial(make_relative, os.path.abspath(get_data("tests/wf"))) |
66 | | - ) |
67 | | - adjustDirObjs(packed, partial(make_relative, os.path.abspath(get_data("tests/wf")))) |
| 44 | + context_dir = os.path.abspath(os.path.dirname(get_data(unpacked))) |
| 45 | + adjustFileObjs(packed, partial(make_relative, context_dir)) |
| 46 | + adjustDirObjs(packed, partial(make_relative, context_dir)) |
68 | 47 |
|
69 | | - assert "$schemas" in packed |
70 | | - packed_schemas = packed["$schemas"] |
71 | | - assert isinstance(packed_schemas, Sized) |
72 | | - assert len(packed_schemas) == len(expect_packed["$schemas"]) |
73 | | - del packed["$schemas"] |
74 | | - del expect_packed["$schemas"] |
| 48 | + yaml = YAML(typ="safe", pure=True) |
| 49 | + with open(get_data(expected)) as packed_file: |
| 50 | + expect_packed = yaml.load(packed_file) |
| 51 | + |
| 52 | + if "$schemas" in expect_packed: |
| 53 | + assert "$schemas" in packed |
| 54 | + packed_schemas = packed["$schemas"] |
| 55 | + assert isinstance(packed_schemas, Sized) |
| 56 | + assert len(packed_schemas) == len(expect_packed["$schemas"]) |
| 57 | + del packed["$schemas"] |
| 58 | + del expect_packed["$schemas"] |
75 | 59 |
|
76 | 60 | assert packed == expect_packed |
77 | 61 |
|
|
0 commit comments