From d6c874ecd5591ff9bbcb6ce336a21a3a1e3d172e Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Wed, 2 Mar 2022 16:31:11 +0000 Subject: [PATCH 1/3] ENH: Allow child backend credentials environment variable to be missing --- tests/test_children.py | 11 +++++++++-- twined/schema/children_schema.json | 2 +- twined/twine.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_children.py b/tests/test_children.py index 5f47c2d..a9a839c 100644 --- a/tests/test_children.py +++ b/tests/test_children.py @@ -72,12 +72,12 @@ def test_no_children(self): Twine().validate_children(source=[]) def test_missing_children(self): - """Test that a twine with children will not validate on an empty children input""" + """Test that a twine with children will not validate on an empty children input.""" with self.assertRaises(exceptions.InvalidValuesContents): Twine(source=self.VALID_TWINE_WITH_CHILDREN).validate_children(source=[]) def test_extra_children(self): - """Test that a twine with no children will not validate a non-empty children input""" + """Test that a twine with no children will not validate a non-empty children input.""" with self.assertRaises(exceptions.InvalidValuesContents): Twine().validate_children(source=self.VALID_CHILD_VALUE) @@ -88,6 +88,13 @@ def test_backend_cannot_be_empty(self): with self.assertRaises(exceptions.InvalidValuesContents): Twine().validate_children(source=single_child_missing_backend) + def test_backend_credentials_environment_variable_can_be_empty(self): + """Test that the backend credentials environment variable of a child can be empty.""" + children = ( + """[{"key": "gis", "id": "some-id", "backend": {"name": "GCPPubSubBackend", "project_name": "blah"}}]""" + ) + Twine(source=self.VALID_TWINE_WITH_CHILDREN).validate_children(source=children) + def test_extra_key_validation_on_empty_twine(self): """Test that children with extra data will not raise a validation error on an empty twine.""" children_values_with_extra_data = """ diff --git a/twined/schema/children_schema.json b/twined/schema/children_schema.json index 80b3778..eed2741 100644 --- a/twined/schema/children_schema.json +++ b/twined/schema/children_schema.json @@ -33,7 +33,7 @@ "type": "string" } }, - "required": ["name", "project_name", "credentials_environment_variable"] + "required": ["name", "project_name"] } ] } diff --git a/twined/twine.py b/twined/twine.py index 5cb2255..4faf357 100644 --- a/twined/twine.py +++ b/twined/twine.py @@ -187,7 +187,7 @@ def _validate_manifest(self, kind, source, cls=None, **kwargs): data["datasets"] = {dataset["name"]: dataset for dataset in data["datasets"]} warnings.warn( message=( - "Datasets belonging to a manifest should be provided as a dictionary mapping their name to" + "Datasets belonging to a manifest should be provided as a dictionary mapping their name to " "themselves. Support for providing a list of datasets will be phased out soon." ), category=DeprecationWarning, From 4a7f5a714bac8ed96dce435be2206931571a8856 Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Wed, 2 Mar 2022 16:32:21 +0000 Subject: [PATCH 2/3] OPS: Increase version number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 79c367d..0b3f599 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="twined", - version="0.2.0", + version="0.2.1", py_modules=[], install_requires=["jsonschema ~= 3.2.0", "python-dotenv"], url="https://www.github.com/octue/twined", From e485347ecea7117da3ad44f1b9fc48882113344b Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Fri, 18 Mar 2022 16:37:06 +0000 Subject: [PATCH 3/3] ENH: Remove support for credentials environment variable name --- tests/test_children.py | 13 ++----------- twined/schema/children_schema.json | 4 ---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/test_children.py b/tests/test_children.py index a9a839c..0631dbb 100644 --- a/tests/test_children.py +++ b/tests/test_children.py @@ -60,8 +60,7 @@ class TestChildrenValidation(BaseTestCase): "id": "some-id", "backend": { "name": "GCPPubSubBackend", - "project_name": "my-project", - "credentials_environment_variable": "GCP_SERVICE_ACCOUNT" + "project_name": "my-project" } } ] @@ -88,13 +87,6 @@ def test_backend_cannot_be_empty(self): with self.assertRaises(exceptions.InvalidValuesContents): Twine().validate_children(source=single_child_missing_backend) - def test_backend_credentials_environment_variable_can_be_empty(self): - """Test that the backend credentials environment variable of a child can be empty.""" - children = ( - """[{"key": "gis", "id": "some-id", "backend": {"name": "GCPPubSubBackend", "project_name": "blah"}}]""" - ) - Twine(source=self.VALID_TWINE_WITH_CHILDREN).validate_children(source=children) - def test_extra_key_validation_on_empty_twine(self): """Test that children with extra data will not raise a validation error on an empty twine.""" children_values_with_extra_data = """ @@ -118,8 +110,7 @@ def test_extra_key_validation_on_valid_twine(self): "id": "some-id", "backend": { "name": "GCPPubSubBackend", - "project_name": "my-project", - "credentials_environment_variable": "GCP_SERVICE_ACCOUNT" + "project_name": "my-project" }, "some_extra_property": "should not be a problem if present" } diff --git a/twined/schema/children_schema.json b/twined/schema/children_schema.json index eed2741..1da053d 100644 --- a/twined/schema/children_schema.json +++ b/twined/schema/children_schema.json @@ -27,10 +27,6 @@ "project_name": { "description": "Name of the Google Cloud Platform (GCP) project the child exists in.", "type": "string" - }, - "credentials_environment_variable": { - "description": "Name of environment variable containing either the absolute path to a Google Cloud Platform credentials JSON file or the JSON itself as a string.", - "type": "string" } }, "required": ["name", "project_name"]