Skip to content

Commit 7fa30a4

Browse files
author
nazarfil
committed
remove not needed methods
1 parent 9467d50 commit 7fa30a4

2 files changed

Lines changed: 1 addition & 74 deletions

File tree

openhexa/sdk/workspaces/current_workspace.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -78,49 +78,7 @@ def configuration(self) -> dict[str, str | dict] | None:
7878
"""
7979
if not self._connected:
8080
return None
81-
try:
82-
workspace_data = OpenHexaClient().workspace(slug=self.slug)
83-
return workspace_data.configuration
84-
except KeyError:
85-
raise WorkspaceConfigError("The workspace configuration is not available in this environment.")
86-
87-
def get_config(self, key: str, default=None) -> str | dict | None:
88-
"""Get a specific configuration value by key.
89-
90-
Parameters
91-
----------
92-
key : str
93-
The configuration key to retrieve
94-
default : any, optional
95-
Default value to return if key is not found
96-
97-
Returns
98-
-------
99-
str | dict | None
100-
The configuration value, or default if key is not found
101-
"""
102-
config = self.configuration
103-
if config is None:
104-
return default
105-
return config.get(key, default)
106-
107-
def has_config(self, key: str) -> bool:
108-
"""Check if a configuration key exists.
109-
110-
Parameters
111-
----------
112-
key : str
113-
The configuration key to check
114-
115-
Returns
116-
-------
117-
bool
118-
True if the key exists in configuration, False otherwise
119-
"""
120-
config = self.configuration
121-
if config is None:
122-
return False
123-
return key in config
81+
return OpenHexaClient().workspace(slug=self.slug)
12482

12583
@property
12684
def database_host(self) -> str:

tests/test_workspace.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -557,34 +557,3 @@ def test_workspace_configuration(self, workspace):
557557
with mock.patch("openhexa.sdk.workspaces.current_workspace.OpenHexaClient") as mock_client:
558558
mock_client.return_value.workspace.return_value = mock_workspace_data
559559
assert workspace.configuration == mock_config
560-
561-
def test_workspace_get_config(self, workspace):
562-
mock_config = {
563-
"api_url": "https://api.example.com",
564-
"debug_mode": "true",
565-
"database_config": {"host": "localhost", "port": 5432},
566-
}
567-
568-
mock_workspace_data = mock.Mock()
569-
mock_workspace_data.configuration = mock_config
570-
571-
with mock.patch("openhexa.sdk.workspaces.current_workspace.OpenHexaClient") as mock_client:
572-
mock_client.return_value.workspace.return_value = mock_workspace_data
573-
574-
assert workspace.get_config("api_url") == "https://api.example.com"
575-
assert workspace.get_config("database_config") == {"host": "localhost", "port": 5432}
576-
assert workspace.get_config("missing_key", "default_value") == "default_value"
577-
assert workspace.get_config("missing_key") is None
578-
579-
def test_workspace_has_config(self, workspace):
580-
mock_config = {"api_url": "https://api.example.com", "debug_mode": "true"}
581-
582-
mock_workspace_data = mock.Mock()
583-
mock_workspace_data.configuration = mock_config
584-
585-
with mock.patch("openhexa.sdk.workspaces.current_workspace.OpenHexaClient") as mock_client:
586-
mock_client.return_value.workspace.return_value = mock_workspace_data
587-
588-
assert workspace.has_config("api_url") is True
589-
assert workspace.has_config("debug_mode") is True
590-
assert workspace.has_config("missing_key") is False

0 commit comments

Comments
 (0)