From 1cb1003a1459700cac5d5b9640f4661e6912b0b8 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Tue, 20 Apr 2021 14:17:07 +0000 Subject: [PATCH] #210: Add leading underscore to instance variables --- datagateway_api/common/config.py | 6 +++--- test/test_config.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/datagateway_api/common/config.py b/datagateway_api/common/config.py index 6cc96e8d..ce2ef8cf 100644 --- a/datagateway_api/common/config.py +++ b/datagateway_api/common/config.py @@ -38,7 +38,7 @@ class Config(object): def __init__(self, path=Path(__file__).parent.parent / "config.json"): self.path = path with open(self.path) as target: - self.config = json.load(target) + self._config = json.load(target) self._check_config_items_exist() @@ -91,7 +91,7 @@ def get_config_value(self, config_key): :return: Config value of the given key """ try: - return self.config[config_key.value] + return self._config[config_key.value] except KeyError: sys.exit(f"Missing config value: {config_key}") @@ -106,7 +106,7 @@ def set_backend_type(self, backend_type): type must be fetched. This must be done using this module (rather than directly importing and checking the Flask app's config) to avoid circular import issues. """ - self.config["backend"] = backend_type + self._config["backend"] = backend_type def get_icat_properties(self): """ diff --git a/test/test_config.py b/test/test_config.py index c7f03e6e..5bb52764 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -19,7 +19,7 @@ def test_valid_get_config_value(self, test_config): assert backend_type == "db" def test_invalid_get_config_value(self, test_config): - del test_config.config["backend"] + del test_config._config["backend"] with pytest.raises(SystemExit): test_config.get_config_value(APIConfigOptions.BACKEND) @@ -36,7 +36,7 @@ def test_valid_config_items_exist(self, backend_type): / "datagateway_api" / "config.json.example", ) - test_config.config["backend"] = backend_type + test_config._config["backend"] = backend_type # Just want to check no SysExit's, so no assert is needed test_config._check_config_items_exist() @@ -52,7 +52,7 @@ def test_invalid_config_items_exist(self): def test_valid_set_backend_type(self, test_config): test_config.set_backend_type("backend_name_changed") - assert test_config.config["backend"] == "backend_name_changed" + assert test_config._config["backend"] == "backend_name_changed" def test_valid_icat_properties(self, test_config): example_icat_properties = {