def test_print_oneline_for_errors_in_resolve_ref() -> None:
    # Issue #141
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path)
    assert isinstance(avsc_names, Names)

    src = "test18.cwl"
    path = get_data("tests/test_schema/" + src)
    assert path
    fullpath = normpath(path)
    with pytest.raises(ValidationException):
        try:
            load_and_validate(document_loader, avsc_names, str(fullpath), True)
        except ValidationException as e:
            msg = to_one_line_messages(e)
            # convert Windows path to Posix path
            if "\\" in fullpath:
                fullpath = "/" + fullpath.lower().replace("\\", "/")
            print("\n", e)
            assert msg.endswith(
                src + ":14:5: Field `type` references unknown identifier "
                "`Filea`, tried file://%s#Filea" % (fullpath)
            )
            raise
def test_for_invalid_yaml1() -> None:
    # Issue 143
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path)
    assert isinstance(avsc_names, Names)

    src = "test16.cwl"
    path = get_data("tests/test_schema/" + src)
    assert path
    with pytest.raises(ValidationException):
        try:
            load_and_validate(
                document_loader,
                avsc_names,
                path,
                True,
            )
        except ValidationException as e:
            msg = str(e)
            print("\n", e)
            assert re.search(src + r":10:7: while scanning a\s+simple\s+key", msg, re.M)
            assert re.search(
                src + r":11:1:   could not\s+find\s+expected ':'$", msg, re.M
            )
            raise
Example #3
0
def test_errors():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    for t in (
            "test_schema/test1.cwl",
            "test_schema/test2.cwl",
            "test_schema/test3.cwl",
            "test_schema/test4.cwl",
            "test_schema/test5.cwl",
            "test_schema/test6.cwl",
            "test_schema/test7.cwl",
            "test_schema/test8.cwl",
            "test_schema/test9.cwl",
            "test_schema/test10.cwl",
            "test_schema/test11.cwl",
            "test_schema/test15.cwl",
    ):
        with pytest.raises(ValidationException):
            try:
                load_and_validate(
                    document_loader,
                    avsc_names,
                    six.text_type(get_data("tests/" + t)),
                    True,
                )
            except ValidationException as e:
                print("\n", e)
                raise
def test_print_oneline_for_errors_in_the_same_line() -> None:
    # Issue #136
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path)
    assert isinstance(avsc_names, Names)

    src = "test17.cwl"
    path = get_data("tests/test_schema/" + src)
    assert path
    with pytest.raises(ValidationException):
        try:
            load_and_validate(
                document_loader,
                avsc_names,
                path,
                True,
            )
        except ValidationException as e:
            msgs = to_one_line_messages(e).splitlines()
            assert len(msgs) == 2, msgs
            assert msgs[0].endswith(src + ":14:5: missing required field `id`")
            assert msgs[1].endswith(
                src + ":14:5: invalid field `aa`, expected one of: 'label', "
                "'secondaryFiles', 'format', 'streamable', 'doc', 'id', "
                "'outputBinding', 'type'"
            )
            print("\n", e)
            raise
def test_for_invalid_yaml2() -> None:
    # Issue 143
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path)
    assert isinstance(avsc_names, Names)

    src = "test19.cwl"
    path = get_data("tests/test_schema/" + src)
    assert path
    with pytest.raises(ValidationException):
        try:
            load_and_validate(
                document_loader,
                avsc_names,
                path,
                True,
            )
        except ValidationException as e:
            msg = str(e)
            assert (
                msg.endswith("expected <block end>, but found ':'")
                or msg.endswith("expected <block end>, but found u':'")
                or re.search(r"mapping with\s+implicit\s+null key$", msg, re.M)
            )
            print("\n", e)
            raise
    def test_print_oneline(self):
        # Issue #135
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        src = "test15.cwl"
        with self.assertRaises(ValidationException):
            try:
                load_and_validate(
                    document_loader, avsc_names,
                    six.text_type(get_data("tests/test_schema/" + src)), True)
            except ValidationException as e:
                msgs = to_one_line_messages(str(e)).splitlines()
                self.assertEqual(len(msgs), 2)
                m = re.match(r'^(.+:\d+:\d+:)(.+)$', msgs[0])
                self.assertTrue(msgs[0].endswith(
                    src +
                    ":11:7: invalid field `invalid_field`, expected one of: 'loadContents', 'position', 'prefix', 'separate', 'itemSeparator', 'valueFrom', 'shellQuote'"
                ))
                self.assertTrue(msgs[1].endswith(
                    src +
                    ":12:7: invalid field `another_invalid_field`, expected one of: 'loadContents', 'position', 'prefix', 'separate', 'itemSeparator', 'valueFrom', 'shellQuote'"
                ))
                print("\n", e)
                raise
def test_print_oneline():
    # Issue #135
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data("tests/test_schema/CommonWorkflowLanguage.yml"))

    src = "test15.cwl"
    with pytest.raises(ValidationException):
        try:
            load_and_validate(
                document_loader,
                avsc_names,
                str(get_data("tests/test_schema/" + src)),
                True,
            )
        except ValidationException as e:
            msgs = to_one_line_messages(e).splitlines()
            assert len(msgs) == 2
            assert msgs[0].endswith(
                src + ":11:7: invalid field `invalid_field`, expected one of: "
                "'loadContents', 'position', 'prefix', 'separate', "
                "'itemSeparator', 'valueFrom', 'shellQuote'")
            assert msgs[1].endswith(
                src +
                ":12:7: invalid field `another_invalid_field`, expected one of: "
                "'loadContents', 'position', 'prefix', 'separate', 'itemSeparator', "
                "'valueFrom', 'shellQuote'")
            print("\n", e)
            raise
Example #8
0
    def test_fp(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        for t in ("foreign/foreign_prop1.cwl", "foreign/foreign_prop2.cwl",
                  "foreign/foreign_prop3.cwl", "foreign/foreign_prop4.cwl",
                  "foreign/foreign_prop5.cwl", "foreign/foreign_prop6.cwl",
                  "foreign/foreign_prop7.cwl"):
            load_and_validate(document_loader,
                              avsc_names,
                              six.text_type(get_data("tests/" + t)),
                              True,
                              strict_foreign_properties=False)

        for t in (
                "foreign/foreign_prop1.cwl",
                "foreign/foreign_prop2.cwl",
                "foreign/foreign_prop4.cwl",
                "foreign/foreign_prop5.cwl",
        ):
            with self.assertRaises(ValidationException):
                try:
                    print(t)
                    load_and_validate(document_loader,
                                      avsc_names,
                                      six.text_type(get_data("tests/" + t)),
                                      True,
                                      strict_foreign_properties=True)
                except ValidationException as e:
                    print("\n", e)
                    raise
Example #9
0
def test_errors() -> None:
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        path)
    assert isinstance(avsc_names, Names)

    for t in (
            "test_schema/test1.cwl",
            "test_schema/test2.cwl",
            "test_schema/test3.cwl",
            "test_schema/test4.cwl",
            "test_schema/test5.cwl",
            "test_schema/test6.cwl",
            "test_schema/test7.cwl",
            "test_schema/test8.cwl",
            "test_schema/test9.cwl",
            "test_schema/test10.cwl",
            "test_schema/test11.cwl",
            "test_schema/test15.cwl",
    ):
        path2 = get_data("tests/" + t)
        assert path2
        with pytest.raises(ValidationException):
            try:
                load_and_validate(
                    document_loader,
                    avsc_names,
                    path2,
                    True,
                )
            except ValidationException as e:
                print("\n", e)
                raise
Example #10
0
def test_error_message15() -> None:
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        path)
    assert isinstance(avsc_names, Names)

    t = "test_schema/test15.cwl"
    match = (
        r"""^.+test15\.cwl:3:1:\s+Object\s+`.+test15\.cwl`\s+is not valid because
\s+tried\s+`CommandLineTool`\s+but
.+test15\.cwl:6:1:\s+the `inputs`\s+field\s+is\s+not valid\s+because
.+test15\.cwl:7:3:\s+item is\s+invalid\s+because
.+test15\.cwl:9:5:\s+the\s+`inputBinding`\s+field\s+is\s+not\s+valid\s+because
.+tried\s+CommandLineBinding\s+but
.+test15\.cwl:11:7:             \*\s+invalid\s+field\s+`invalid_field`,\s+expected\s+"""
        +
        r"""one\s+of:\s+'loadContents',\s+'position',\s+'prefix',\s+'separate',"""
        + r"""\s+'itemSeparator',\s+'valueFrom',\s+'shellQuote'
.+test15\.cwl:12:7:             \*\s+invalid\s+field\s+`another_invalid_field`,"""
        +
        r"""\s+expected one\s+of:\s+'loadContents',\s+'position',\s+'prefix',"""
        +
        r"""\s+'separate',\s+'itemSeparator',\s+'valueFrom',\s+'shellQuote'$"""
    )
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          str(get_data("tests/" + t)), True)
Example #11
0
    def test_print_oneline_for_errors_in_the_same_line(self):
        # Issue #136
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        src = "test17.cwl"
        with self.assertRaises(ValidationException):
            try:
                load_and_validate(
                    document_loader, avsc_names,
                    six.text_type(get_data("tests/test_schema/" + src)), True)
            except ValidationException as e:
                msgs = to_one_line_messages(str(e)).splitlines()
                self.assertEqual(len(msgs), 3)
                self.assertTrue(msgs[0].endswith(
                    src + ":9:1: the `outputs` field is not valid because"))
                self.assertTrue(
                    msgs[1].endswith(src +
                                     ":13:5: missing required field `id`"))
                self.assertTrue(msgs[2].endswith(
                    src +
                    ":13:5: invalid field `aa`, expected one of: 'label', 'secondaryFiles', 'format', 'streamable', 'doc', 'id', 'outputBinding', 'type'"
                ))
                print("\n", e)
                raise
def test_for_invalid_yaml2():
    # Issue 143
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    src = "test19.cwl"
    try:
        load_and_validate(
            document_loader,
            avsc_names,
            six.text_type(get_data("tests/test_schema/" + src)),
            True,
        )
    except RuntimeError as e:
        msg = reformat_yaml_exception_message(
            strip_dup_lineno(six.text_type(e)))
        assert msg.endswith(
            src + ":2:1: expected <block end>, but found ':'") or msg.endswith(
                src + ":2:1: expected <block end>, but found u':'")
        return
    except ValidationException as e:
        msgs = str(strip_dup_lineno(six.text_type(e)))
        print(msgs)
        # weird splits due to differing path length on MS Windows
        # & during the release tests
        assert "{}:2:1: Object".format(src) in msgs
        assert "is not valid because" in msgs
        assert "`CommandLineTool`" in msgs
        assert "mapping with" in msgs
        assert "implicit" in msgs
        assert "null key" in msgs
        return
    assert False, "Missing RuntimeError or ValidationException"
Example #13
0
    def test_errors(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        for t in ("test_schema/test1.cwl",
                  "test_schema/test2.cwl",
                  "test_schema/test3.cwl",
                  "test_schema/test4.cwl",
                  "test_schema/test5.cwl",
                  "test_schema/test6.cwl",
                  "test_schema/test7.cwl",
                  "test_schema/test8.cwl",
                  "test_schema/test9.cwl",
                  "test_schema/test10.cwl",
                  "test_schema/test11.cwl",
                  "test_schema/test12.cwl",
                  "test_schema/test13.cwl",
                  "test_schema/test14.cwl",
                  "test_schema/test15.cwl"):
            with self.assertRaises(ValidationException):
                try:
                    load_and_validate(document_loader, avsc_names,
                            six.text_type(get_data("tests/"+t)), True)
                except ValidationException as e:
                    print("\n", e)
                    raise
Example #14
0
 def load_cwl(self, src):
     with self.assertRaises(ValidationException):
         try:
             load_and_validate(self.document_loader, self.avsc_names,
                               six.text_type(get_data(test_dir_name + src)),
                               True)
         except ValidationException as e:
             # msgs = to_one_line_messages(str(e)).splitlines()
             print("\n", e)
             raise
Example #15
0
def test_error_message2():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test2.cwl"
    match = r"""
^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference to
\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #16
0
def test_error_message9():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test9.cwl"
    match = (r"""^.+test9\.cwl:7:1: checking field\s+`steps`
.+test9\.cwl:8:3:   checking object\s+`.+test9\.cwl#step1`
.+test9\.cwl:9:5:     `scatterMethod`\s+field\s+is\s+""" +
             r"""int,\s+expected\s+string,\s+list,\s+or a\s+dict.$""")
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #17
0
def test_error_message4():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test4.cwl"
    match = r"""
^.+test4\.cwl:5:1: checking field\s+`outputs`
.+test4\.cwl:6:3:   checking object\s+`.+test4\.cwl#bar`
\s+`type` field is\s+int,\s+expected\s+string,\s+list, or\s+a\s+dict.$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #18
0
def test_error_message11():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test11.cwl"
    match = r"""
^.+test11\.cwl:7:1: checking field\s+`steps`
.+test11\.cwl:8:3:   checking object\s+`.+test11\.cwl#step1`
.+test11\.cwl:9:5:     Field `run`\s+contains\s+undefined\s+reference to
\s+`file://.+/tests/test_schema/blub\.cwl`$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #19
0
def test_error_message3():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test3.cwl"
    match = r"""
^.+test3\.cwl:5:1: checking field\s+`outputs`
.+test3\.cwl:6:3:   checking object\s+`.+test3\.cwl#bar`
\s+Field `type`\s+references\s+unknown\s+identifier\s+`xstring`,\s+tried
\s+file://.+/tests/test_schema/test3\.cwl#xstring$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #20
0
    def test_errors_previously_defined_dict_key(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        for t in ("test_schema/test12.cwl", "test_schema/test13.cwl",
                  "test_schema/test14.cwl"):
            with self.assertRaises(ValidationException):
                try:
                    load_and_validate(document_loader, avsc_names,
                                      six.text_type(get_data("tests/" + t)),
                                      True)
                except ValidationException as e:
                    print("\n", e)
                    raise
Example #21
0
def test_error_message1():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test1.cwl"
    match = (
        r"""^.+test1\.cwl:2:1: Object\s+`.+test1\.cwl`\s+is\s+not valid """ +
        r"""because\s+tried `Workflow`\s+but
\s+\* missing\s+required\s+field\s+`inputs`
\s+\* missing\s+required\s+field\s+`outputs`
\s+\* missing\s+required\s+field\s+`steps`$""")
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #22
0
def test_error_message5():
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

    t = "test_schema/test5.cwl"
    match = r"""
^.+test5\.cwl:2:1: Object\s+`.+test5\.cwl`\s+is\s+not valid because
\s+tried `Workflow`\s+but
.+test5\.cwl:7:1:     the `steps`\s+field\s+is\s+not\s+valid\s+because
\s+tried array\s+of\s+<WorkflowStep>\s+but
.+test5\.cwl:7:9:         item is\s+invalid\s+because
\s+is not a\s+dict$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          six.text_type(get_data("tests/" + t)), True)
Example #23
0
def test_error_message2() -> None:
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        path)
    assert isinstance(avsc_names, Names)

    t = "test_schema/test2.cwl"
    match = r"""
^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference to
\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[1:]
    path2 = get_data("tests/" + t)
    assert path2
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names, path2, True)
Example #24
0
    def test_error_message1(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        t = "test_schema/test1.cwl"
        with self.assertRaises(ValidationException) as e:
            load_and_validate(document_loader, avsc_names,
                              six.text_type(get_data("tests/" + t)), True)
        self.assertTrue(
            re.match(
                r'''
^.+test1\.cwl:2:1: Object\s+`.+test1\.cwl`\s+is\s+not valid because\s+tried `Workflow`\s+but
\s+\* missing\s+required\s+field\s+`inputs`
\s+\* missing\s+required\s+field\s+`outputs`
\s+\* missing\s+required\s+field\s+`steps`$'''[1:], str(e.exception)))
Example #25
0
    def test_error_message2(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        t = "test_schema/test2.cwl"
        with self.assertRaises(ValidationException) as e:
            load_and_validate(document_loader, avsc_names,
                              six.text_type(get_data("tests/" + t)), True)
        self.assertTrue(
            re.match(
                r'''
^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference to
\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$'''[1:],
                str(e.exception)),
            str(e.exception) + ' is not matched.')
Example #26
0
 def load_cwl(self, src: str) -> Tuple[Any, Dict[str, Any]]:
     path = get_data(test_dir_name + src)
     assert path
     assert isinstance(self.avsc_names, Names)
     res = load_and_validate(self.document_loader, self.avsc_names, path,
                             True)
     return res
Example #27
0
def test_error_message8() -> None:
    path = get_data("tests/test_schema/CommonWorkflowLanguage.yml")
    assert path
    document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
        path)
    assert isinstance(avsc_names, Names)

    t = "test_schema/test8.cwl"
    match = r"""
^.+test8\.cwl:7:1: checking field\s+`steps`
.+test8\.cwl:8:3:   checking object\s+`.+test8\.cwl#step1`
.+test8\.cwl:9:5:     Field\s+`scatterMethod`\s+contains\s+undefined\s+reference\s+to
\s+`file:///.+/tests/test_schema/abc`$"""[1:]
    with pytest.raises(ValidationException, match=match):
        load_and_validate(document_loader, avsc_names,
                          str(get_data("tests/" + t)), True)
Example #28
0
    def test_error_message11(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        t = "test_schema/test11.cwl"
        with self.assertRaises(ValidationException) as e:
            load_and_validate(document_loader, avsc_names,
                              six.text_type(get_data("tests/" + t)), True)
        self.assertTrue(
            re.match(
                r'''
^.+test11\.cwl:7:1: checking field\s+`steps`
.+test11\.cwl:8:3:   checking object\s+`.+test11\.cwl#step1`
.+test11\.cwl:9:5:     Field `run`\s+contains\s+undefined\s+reference to
\s+`file://.+/tests/test_schema/blub\.cwl`$'''[1:], str(e.exception)),
            str(e.exception) + ' is not matched.')
Example #29
0
 def load_cwl(self, src: str) -> None:
     path = get_data(test_dir_name + src)
     assert path
     assert isinstance(self.avsc_names, Names)
     with pytest.raises(ValidationException):
         try:
             load_and_validate(
                 self.document_loader,
                 self.avsc_names,
                 path,
                 True,
             )
         except ValidationException as e:
             # msgs = to_one_line_messages(str(e)).splitlines()
             print("\n", e)
             raise
Example #30
0
    def test_error_message4(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        t = "test_schema/test4.cwl"
        with self.assertRaises(ValidationException) as e:
            load_and_validate(document_loader, avsc_names,
                              six.text_type(get_data("tests/" + t)), True)
        self.assertTrue(
            re.match(
                r'''
^.+test4\.cwl:5:1: checking field\s+`outputs`
.+test4\.cwl:6:3:   checking object\s+`.+test4\.cwl#bar`
\s+`type` field is\s+int,\s+expected\s+string,\s+list, or\s+a\s+dict.$'''[1:],
                str(e.exception)),
            str(e.exception) + ' is not matched.')
Example #31
0
    def test_error_message3(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            get_data(u"tests/test_schema/CommonWorkflowLanguage.yml"))

        t = "test_schema/test3.cwl"
        with self.assertRaises(ValidationException) as e:
            load_and_validate(document_loader, avsc_names,
                              six.text_type(get_data("tests/" + t)), True)
        self.assertTrue(
            re.match(
                r'''
^.+test3\.cwl:5:1: checking field\s+`outputs`
.+test3\.cwl:6:3:   checking object\s+`.+test3\.cwl#bar`
\s+Field `type`\s+references\s+unknown\s+identifier\s+`xstring`,\s+tried
\s+file://.+/tests/test_schema/test3\.cwl#xstring$'''[1:], str(e.exception)),
            str(e.exception) + ' is not matched.')
Example #32
0
def parse_workflow(cwlpath):
    (document_loader, avsc_names, schema_metadata) = process.get_schema()
    fileuri = "file://" + cwlpath
    workflowobj = document_loader.fetch(fileuri)
    # If strict is true, names are required everywhere (among other requirements)
    strict = False
    # This updates from draft2 to draft3
    workflowobj = update.update(workflowobj, document_loader, fileuri)
    document_loader.idx.clear()
    processobj, metadata = schema.load_and_validate(document_loader, avsc_names, workflowobj, strict)
    return processobj
    def test_errors(self):
        document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(
            u"schema_salad/tests/test_schema/CommonWorkflowLanguage.yml")
        avsc_names = cast(Names, avsc_names)

        for t in ("test_schema/test1.cwl",
                  "test_schema/test2.cwl",
                  "test_schema/test3.cwl",
                  "test_schema/test4.cwl",
                  "test_schema/test5.cwl",
                  "test_schema/test6.cwl",
                  "test_schema/test7.cwl",
                  "test_schema/test8.cwl",
                  "test_schema/test9.cwl",
                  "test_schema/test10.cwl",
                  "test_schema/test11.cwl"):
            with self.assertRaises(ValidationException):
                try:
                    load_and_validate(document_loader, avsc_names, unicode("schema_salad/tests/"+t), True)
                except ValidationException as e:
                    print "\n", e
                    raise