File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class ToolSettings(BaseSettings):
13
13
14
14
class GrafanaSettings (BaseSettings ):
15
15
model_config : SettingsConfigDict = SettingsConfigDict (
16
- env_prefix = "GRAFANA_" , env_file = ".env"
16
+ env_prefix = "GRAFANA_" , env_file = ".env" , env_nested_delimiter = "__"
17
17
)
18
18
19
19
url : str = "http://localhost:3000"
Original file line number Diff line number Diff line change
1
+ import os
2
+ from unittest .mock import patch
3
+
1
4
from mcp_grafana .settings import GrafanaSettings
2
5
3
6
@@ -7,3 +10,21 @@ def test_settings():
7
10
assert settings .api_key is None
8
11
assert settings .tools .search .enabled
9
12
assert settings .tools .search .limit == 1000
13
+
14
+
15
+ @patch .dict (
16
+ os .environ ,
17
+ {
18
+ "GRAFANA_URL" : "http://localhost:3001" ,
19
+ "GRAFANA_API_KEY" : "my-api-key" ,
20
+ "GRAFANA_TOOLS__SEARCH__ENABLED" : "false" ,
21
+ "GRAFANA_TOOLS__SEARCH__LIMIT" : "100" ,
22
+ },
23
+ )
24
+ def test_settings_from_env ():
25
+ # Test we can instantiate settings from environment variables with delimiters.
26
+ settings = GrafanaSettings ()
27
+ assert settings .url == "http://localhost:3001"
28
+ assert settings .api_key == "my-api-key"
29
+ assert not settings .tools .search .enabled
30
+ assert settings .tools .search .limit == 100
You can’t perform that action at this time.
0 commit comments