Skip to main content
Glama
test_settings.py3.68 kB
"""Tests for DataBeak settings functionality.""" import os from unittest.mock import patch from databeak.core.settings import DatabeakSettings class TestDatabeakSettings: """Test DataBeak settings configuration.""" def test_default_settings(self) -> None: """Test default settings configuration.""" settings = DatabeakSettings() # History functionality removed - test other defaults assert settings.max_download_size_mb == 100 assert settings.session_timeout == 3600 assert settings.max_anomaly_sample_size == 10000 def test_settings_with_custom_values(self) -> None: """Test settings with custom values.""" settings = DatabeakSettings(max_download_size_mb=200, session_timeout=7200) assert settings.max_download_size_mb == 200 assert settings.session_timeout == 7200 def test_environment_variable_override(self) -> None: """Test that environment variables override defaults.""" with patch.dict( os.environ, { "DATABEAK_MAX_DOWNLOAD_SIZE_MB": "200", "DATABEAK_SESSION_TIMEOUT": "14400", }, ): settings = DatabeakSettings() assert settings.max_download_size_mb == 200 assert settings.session_timeout == 14400 def test_case_insensitive_env_var(self) -> None: """Test that environment variables are case insensitive.""" with patch.dict(os.environ, {"DATABEAK_MAX_DOWNLOAD_SIZE_MB": "512"}): settings = DatabeakSettings() assert settings.max_download_size_mb == 512 class TestDatabeakSettingsIntegration: """Test DataBeak settings integration with sessions.""" def test_settings_are_configurable(self) -> None: """Test that settings can be configured multiple ways.""" # Test 1: Direct instantiation settings1 = DatabeakSettings(max_download_size_mb=512) assert settings1.max_download_size_mb == 512 # Test 2: Environment variable with patch.dict(os.environ, {"DATABEAK_MAX_DOWNLOAD_SIZE_MB": "2048"}): settings2 = DatabeakSettings() assert settings2.max_download_size_mb == 2048 # Test 3: Default with patch.dict(os.environ, {}, clear=True): # Clear any existing env vars if "DATABEAK_MAX_DOWNLOAD_SIZE_MB" in os.environ: del os.environ["DATABEAK_MAX_DOWNLOAD_SIZE_MB"] settings3 = DatabeakSettings() assert settings3.max_download_size_mb == 100 class TestSettingsDocumentation: """Test that settings behavior matches documentation.""" def test_env_prefix_documentation(self) -> None: """Test that DATABEAK_ prefix works as documented.""" with patch.dict(os.environ, {"DATABEAK_URL_TIMEOUT_SECONDS": "60"}): settings = DatabeakSettings() assert settings.url_timeout_seconds == 60 def test_default_values_documentation(self) -> None: """Test that default values match documentation.""" # Clear environment and test default values with patch.dict(os.environ, {}, clear=True): for var in [ "DATABEAK_MAX_DOWNLOAD_SIZE_MB", "DATABEAK_SESSION_TIMEOUT", ]: if var in os.environ: del os.environ[var] settings = DatabeakSettings() assert settings.max_download_size_mb == 100, "Default URL size limit should be 100 MB" assert settings.session_timeout == 3600, ( "Default session timeout should be 3600 seconds" )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jonpspri/databeak'

If you have feedback or need assistance with the MCP directory API, please join our Discord server