Skip to content

Commit

Permalink
#210: Add leading underscore to instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Apr 20, 2021
1 parent 5f2b33e commit 1cb1003
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions datagateway_api/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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}")

Expand All @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand All @@ -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 = {
Expand Down

0 comments on commit 1cb1003

Please sign in to comment.