Exemplo n.º 1
0
    def test_get_expressions(self):
        test_cwl_yaml = yaml.round_trip_load(TEST_CWL)
        schema = process.get_schema("v1.0")[1].names["CommandLineTool"]

        exprs = get_expressions(test_cwl_yaml, schema)

        self.assertEqual(len(exprs), 1)
def test_get_expressions():
    test_cwl_yaml = yaml.round_trip_load(TEST_CWL)
    schema = process.get_schema("v1.0")[1].names["CommandLineTool"]

    exprs = validate_js.get_expressions(test_cwl_yaml, schema)

    assert len(exprs) == 1
Exemplo n.º 3
0
    def test_validate_js_expressions(self, print_js_hint_messages):
        test_cwl_yaml = yaml.round_trip_load(TEST_CWL)
        schema = process.get_schema("v1.0")[1].names["CommandLineTool"]

        validate_js_expressions(test_cwl_yaml, schema)

        assert print_js_hint_messages.call_args is not None
        assert len(print_js_hint_messages.call_args[0]) > 0
def test_validate_js_expressions(mocker):
    test_cwl_yaml = yaml.round_trip_load(TEST_CWL)
    schema = process.get_schema("v1.0")[1].names["CommandLineTool"]

    mocker.patch("cwltool.validate_js.print_js_hint_messages")
    validate_js.validate_js_expressions(test_cwl_yaml, schema)

    assert validate_js.print_js_hint_messages.call_args is not None
    assert len(validate_js.print_js_hint_messages.call_args[0]) > 0
Exemplo n.º 5
0
def test_get_expressions() -> None:
    test_cwl_yaml = yaml.main.round_trip_load(TEST_CWL)
    schema = process.get_schema("v1.0")[1]
    assert isinstance(schema, Names)
    clt_schema = schema.names["CommandLineTool"]

    exprs = validate_js.get_expressions(test_cwl_yaml, clt_schema)

    assert len(exprs) == 1
Exemplo n.º 6
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
Exemplo n.º 7
0
def test_validate_js_expressions(mocker: Any) -> None:
    test_cwl_yaml = yaml.main.round_trip_load(TEST_CWL)
    schema = process.get_schema("v1.0")[1]
    assert isinstance(schema, Names)
    clt_schema = schema.names["CommandLineTool"]

    mocker.patch("cwltool.validate_js._logger")
    # mocker.patch("cwltool.validate_js.print_js_hint_messages")
    validate_js.validate_js_expressions(test_cwl_yaml, clt_schema)

    validate_js._logger.warning.assert_called_with(
        " JSHINT: (function(){return ((kjdbfkjd));})()\n JSHINT:                      ^\n JSHINT: W117: 'kjdbfkjd' is not defined."
    )  # type: ignore
Exemplo n.º 8
0
def load_nocheck(upstream):
    loading_context, workflowobj, uri = cwltool.load_tool.fetch_document(
        upstream)

    (sch_document_loader, avsc_names) = \
        get_schema(workflowobj["cwlVersion"])[:2]

    cp = sch_document_loader.ctx.copy()
    cp["upstream"] = {"@type": "@id"}
    sch_document_loader = schema_salad.ref_resolver.Loader(cp)

    document, metadata = sch_document_loader.resolve_all(workflowobj,
                                                         uri,
                                                         checklinks=False)

    return document, loading_context
 def validate_js_expressions_strict(tool: dict):
     """
     Run cwltool function to validate JS in an app
     :param tool: CWL dict
     """
     data = ruamel.yaml.load(ruamel.yaml.dump(tool),
                             ruamel.yaml.RoundTripLoader)
     schema = get_schema(tool['cwlVersion'])[1].names[tool['class']]
     add_lc_filename(data, data.get('label', 'input_document'))
     jshint_options = {
         "includewarnings": [
             "W117",  # <VARIABLE> not defined
             "W104",
             "W119"  # using ES6 features
         ],
         "strict": "implied",
         "esversion": 5
     }
     validate_js_expressions(data, schema, jshint_options)