From 62ed8312acadacf25189ce5d5da0f37c016739dd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 16 Jun 2017 13:04:31 -0400 Subject: [PATCH] 2411: Fix tests to accommodate copyright notices. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/crunchstat/crunchstat_test.go | 2 +- sdk/cwl/tests/matcher.py | 5 +++++ sdk/cwl/tests/test_job.py | 4 ++-- sdk/cwl/tests/test_submit.py | 8 +++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/crunchstat/crunchstat_test.go b/lib/crunchstat/crunchstat_test.go index 697f2352d5..02954b8bf7 100644 --- a/lib/crunchstat/crunchstat_test.go +++ b/lib/crunchstat/crunchstat_test.go @@ -56,7 +56,7 @@ func TestReadAllOrWarnSuccess(t *testing.T) { if err != nil { t.Fatalf("got error %s", err) } - if matched, err := regexp.MatchString("^package crunchstat\n", string(data)); err != nil || !matched { + if matched, err := regexp.MatchString("\npackage crunchstat\n", string(data)); err != nil || !matched { t.Fatalf("data failed regexp: err %v, matched %v", err, matched) } } diff --git a/sdk/cwl/tests/matcher.py b/sdk/cwl/tests/matcher.py index d3c93168e1..892586247c 100644 --- a/sdk/cwl/tests/matcher.py +++ b/sdk/cwl/tests/matcher.py @@ -1,5 +1,6 @@ import difflib import json +import re class JsonDiffMatcher(object): @@ -21,3 +22,7 @@ class JsonDiffMatcher(object): actual_json.splitlines(1), fromfile="Expected", tofile="Actual"))) return True + + +def StripYAMLComments(yml): + return re.sub(r'(?ms)^(#.*?\n)*\n*', '', yml) diff --git a/sdk/cwl/tests/test_job.py b/sdk/cwl/tests/test_job.py index a71d1d8e07..0d26d04522 100644 --- a/sdk/cwl/tests/test_job.py +++ b/sdk/cwl/tests/test_job.py @@ -14,7 +14,7 @@ from arvados.errors import ApiError from schema_salad.ref_resolver import Loader from schema_salad.sourceline import cmap from .mock_discovery import get_rootDesc -from .matcher import JsonDiffMatcher +from .matcher import JsonDiffMatcher, StripYAMLComments if not os.getenv('ARVADOS_DEBUG'): logging.getLogger('arvados.cwl-runner').setLevel(logging.WARN) @@ -333,7 +333,7 @@ class TestWorkflow(unittest.TestCase): it.next().run() with open("tests/wf/scatter2_subwf.cwl") as f: - subwf = f.read() + subwf = StripYAMLComments(f.read()) runner.api.jobs().create.assert_called_with( body=JsonDiffMatcher({ diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py index 2e682830b4..83a75b6941 100644 --- a/sdk/cwl/tests/test_submit.py +++ b/sdk/cwl/tests/test_submit.py @@ -14,7 +14,7 @@ import arvados_cwl import arvados_cwl.runner import arvados.keep -from .matcher import JsonDiffMatcher +from .matcher import JsonDiffMatcher, StripYAMLComments from .mock_discovery import get_rootDesc import ruamel.yaml as yaml @@ -1017,7 +1017,8 @@ class TestCreateTemplate(unittest.TestCase): class TestCreateWorkflow(unittest.TestCase): existing_workflow_uuid = "zzzzz-7fd4e-validworkfloyml" - expect_workflow = open("tests/wf/expect_packed.cwl").read() + expect_workflow = StripYAMLComments( + open("tests/wf/expect_packed.cwl").read()) @stubs def test_create(self, stubs): @@ -1164,7 +1165,8 @@ class TestCreateWorkflow(unittest.TestCase): capture_stdout, sys.stderr, api_client=stubs.api) self.assertEqual(exited, 0) - expect_workflow = open("tests/collection_per_tool/collection_per_tool_packed.cwl").read() + toolfile = "tests/collection_per_tool/collection_per_tool_packed.cwl" + expect_workflow = StripYAMLComments(open(toolfile).read()) body = { "workflow": { -- 2.30.2