<commit_before><commit_msg>test_rdfprint.py: Add tests for printrdf functionality<commit_after>from __future__ import absolute_import
import unittest

from six import StringIO
from cwltool.main import main

class RDF_Print(unittest.TestCase):

    def test_rdf_print(self):
        self.maxDiff = None

        expected_output = """@prefix CommandLineBinding: <https://w3id.org/cwl/cwl#CommandLineBinding/> .
@prefix CommandLineTool: <https://w3id.org/cwl/cwl#CommandLineTool/> .
@prefix CommandOutputBinding: <https://w3id.org/cwl/cwl#CommandOutputBinding/> .
@prefix Dirent: <https://w3id.org/cwl/cwl#Dirent/> .
@prefix DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/> .
@prefix EnvVarRequirement: <https://w3id.org/cwl/cwl#EnvVarRequirement/> .
@prefix EnvironmentDef: <https://w3id.org/cwl/cwl#EnvironmentDef/> .
@prefix ExpressionTool: <https://w3id.org/cwl/cwl#ExpressionTool/> .
@prefix File: <https://w3id.org/cwl/cwl#File/> .
@prefix InlineJavascriptRequirement: <https://w3id.org/cwl/cwl#InlineJavascriptRequirement/> .
@prefix LinkMergeMethod: <https://w3id.org/cwl/cwl#LinkMergeMethod/> .
@prefix Parameter: <https://w3id.org/cwl/cwl#Parameter/> .
@prefix ResourceRequirement: <https://w3id.org/cwl/cwl#ResourceRequirement/> .
@prefix ScatterMethod: <https://w3id.org/cwl/cwl#ScatterMethod/> .
@prefix SchemaDefRequirement: <https://w3id.org/cwl/cwl#SchemaDefRequirement/> .
@prefix SoftwarePackage: <https://w3id.org/cwl/cwl#SoftwarePackage/> .
@prefix SoftwareRequirement: <https://w3id.org/cwl/cwl#SoftwareRequirement/> .
@prefix Workflow: <https://w3id.org/cwl/cwl#Workflow/> .
@prefix cwl: <https://w3id.org/cwl/cwl#> .
@prefix ns1: <rdfs:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sld: <https://w3id.org/cwl/salad#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl> a cwl:Workflow ;
    Workflow:steps <https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl#step0> ;
    cwl:cwlVersion cwl:v1.0 ;
    cwl:outputs <https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl#response> ;
    ns1:comment "Outputs a message using echo" ;
    ns1:label "Hello World" .

<https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl#response> cwl:outputSource <https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl#step0/response> ;
    sld:type cwl:File .
"""

        argsl = ['--print-rdf', 'https://raw.githubusercontent.com/common-workflow-language/workflows/master/workflows/hello/hello.cwl']

        # capture stdout
        out = StringIO()
        main(argsl=argsl, stdout=out)
        # check substring in the actual print-rdf
        self.assertTrue(expected_output in out.getvalue(), True)
{'fraction_non_alphanumeric': 0.16290480863591755, 'fraction_numerical': 0.017337258750408896, 'mean_word_length': 4.570127504553734, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 26, 'lorem ipsum': 0, 'www.': 4, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3912801', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1115, 'n_words': 143}