From 19f19e53c0b75265058c74237c63710cd556e5f5 Mon Sep 17 00:00:00 2001 From: Julianus Pfeuffer Date: Mon, 31 May 2021 16:21:29 +0200 Subject: [PATCH 1/5] [FIX] schema validation with empty default str --- nf_core/schema.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nf_core/schema.py b/nf_core/schema.py index 17fa6ed783..b41258d95d 100644 --- a/nf_core/schema.py +++ b/nf_core/schema.py @@ -114,7 +114,8 @@ def sanitise_param_default(self, param): # For everything else, an empty string is an empty string if isinstance(param["default"], str) and param["default"].strip() == "": - return "" + param["default"] = "" + return param # Integers if param["type"] == "integer": From 90e9204560ea9973186078a33cd0ac9ba10c0fe2 Mon Sep 17 00:00:00 2001 From: Julianus Pfeuffer Date: Mon, 31 May 2021 16:32:56 +0200 Subject: [PATCH 2/5] Try adding test --- tests/test_schema.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_schema.py b/tests/test_schema.py index 7d37636a0d..360a062dd2 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -127,6 +127,15 @@ def test_validate_params_pass(self): self.schema_obj.load_schema() self.schema_obj.input_params = {"input": "fubar"} assert self.schema_obj.validate_params() + + def test_validate_params_pass_ext(self): + """Try validating an extended set of parameters against a schema""" + self.schema_obj.schema = { + "properties": {"foo": {"type": "string"}, "bar": {"type": "string", "default": ""}}, + "required": ["foo"] + } + self.schema_obj.params + assert self.schema_obj.validate_params() def test_validate_params_fail(self): """Check that False is returned if params don't validate against a schema""" From 4f15fe2852abebbd0e36f49df1f99f86ad36db8b Mon Sep 17 00:00:00 2001 From: Julianus Pfeuffer Date: Mon, 31 May 2021 16:44:12 +0200 Subject: [PATCH 3/5] remove leftover line --- tests/test_schema.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_schema.py b/tests/test_schema.py index 360a062dd2..b20f54efc3 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -134,7 +134,6 @@ def test_validate_params_pass_ext(self): "properties": {"foo": {"type": "string"}, "bar": {"type": "string", "default": ""}}, "required": ["foo"] } - self.schema_obj.params assert self.schema_obj.validate_params() def test_validate_params_fail(self): From 690ee2f67991fb4d24520fbc1ca44e98725609a5 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Wed, 17 Nov 2021 00:29:46 +0100 Subject: [PATCH 4/5] Rerun black --- tests/test_schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_schema.py b/tests/test_schema.py index 6eb3dbc08e..a15bb07be5 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -127,12 +127,12 @@ def test_validate_params_pass(self): self.schema_obj.load_schema() self.schema_obj.input_params = {"input": "fubar.csv"} assert self.schema_obj.validate_params() - + def test_validate_params_pass_ext(self): """Try validating an extended set of parameters against a schema""" self.schema_obj.schema = { "properties": {"foo": {"type": "string"}, "bar": {"type": "string", "default": ""}}, - "required": ["foo"] + "required": ["foo"], } assert self.schema_obj.validate_params() From 0774214acf0dfa38c6b93c99eb6d7f8377699300 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Wed, 17 Nov 2021 00:35:48 +0100 Subject: [PATCH 5/5] Remove new test --- tests/test_schema.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_schema.py b/tests/test_schema.py index a15bb07be5..175b23880c 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -128,14 +128,6 @@ def test_validate_params_pass(self): self.schema_obj.input_params = {"input": "fubar.csv"} assert self.schema_obj.validate_params() - def test_validate_params_pass_ext(self): - """Try validating an extended set of parameters against a schema""" - self.schema_obj.schema = { - "properties": {"foo": {"type": "string"}, "bar": {"type": "string", "default": ""}}, - "required": ["foo"], - } - assert self.schema_obj.validate_params() - def test_validate_params_fail(self): """Check that False is returned if params don't validate against a schema""" # Load the template schema