refactor(generate_default_settings):

This commit is contained in:
Alexander Myasoedov
2025-03-02 19:05:23 +02:00
parent ad6e0dbbc8
commit f8102d1ee9
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ Init config
```shell ```shell
agentic_security init agentic_security init
2025-01-08 20:12:02.449 | INFO | agentic_security.lib:generate_default_cfg:324 - Default configuration generated successfully to agesec.toml. 2025-01-08 20:12:02.449 | INFO | agentic_security.lib:generate_default_settings:324 - Default configuration generated successfully to agesec.toml.
``` ```
+1 -1
View File
@@ -39,7 +39,7 @@ class CLI:
Generate the default CI configuration file. Generate the default CI configuration file.
""" """
sys.path.append(os.path.dirname(".")) sys.path.append(os.path.dirname("."))
AgenticSecurity().generate_default_cfg(host, port) AgenticSecurity().generate_default_settings(host, port)
i = init i = init
+2 -2
View File
@@ -24,7 +24,7 @@ class SettingsMixin:
def get_or_create_config(self) -> bool: def get_or_create_config(self) -> bool:
if not self.has_local_config(): if not self.has_local_config():
self.generate_default_cfg() self.generate_default_settings()
return False return False
self.load_config(self.default_path) self.load_config(self.default_path)
settings_version = self.get_config_value("general.version") settings_version = self.get_config_value("general.version")
@@ -86,7 +86,7 @@ class SettingsMixin:
return default return default
return value return value
def generate_default_cfg(self, host: str = "0.0.0.0", port: int = 8718): def generate_default_settings(self, host: str = "0.0.0.0", port: int = 8718):
# Accept host / port as parameters # Accept host / port as parameters
with open(self.default_path, "w") as f: with open(self.default_path, "w") as f:
f.write( f.write(
+3 -3
View File
@@ -157,7 +157,7 @@ class TestLibraryLevel:
class TestEntrypointCI: class TestEntrypointCI:
def test_generate_default_cfg_to_tmp_path(self): def test_generate_default_cfg_to_tmp_path(self):
""" """
Test that the `generate_default_cfg` method generates a valid default config file in a temporary path. Test that the `generate_default_settings` method generates a valid default config file in a temporary path.
""" """
# Create a temporary directory # Create a temporary directory
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
@@ -168,7 +168,7 @@ class TestEntrypointCI:
# Generate the default configuration # Generate the default configuration
security = AgenticSecurity() security = AgenticSecurity()
security.generate_default_cfg() security.generate_default_settings()
# Check that the config file was created at the temporary path # Check that the config file was created at the temporary path
assert os.path.exists(temp_path), f"{temp_path} file should be generated." assert os.path.exists(temp_path), f"{temp_path} file should be generated."
@@ -193,7 +193,7 @@ class TestEntrypointCI:
# Generate the default configuration # Generate the default configuration
security = AgenticSecurity() security = AgenticSecurity()
security.generate_default_cfg() security.generate_default_settings()
# Load the generated configuration # Load the generated configuration
AgenticSecurity.load_config(temp_path) AgenticSecurity.load_config(temp_path)