Coverage for src/dmxfy/config/config.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2025-08-12 11:32 +0800

1import os 

2 

3from dmxfy.exceptions.exceptions import ConfigurationError 

4 

5 

6class Config: 

7 """Configuration management for DMXFY""" 

8 

9 def __init__(self) -> None: 

10 self._api_key: str | None = None 

11 self._load_config() 

12 

13 def _load_config(self) -> None: 

14 """Load configuration from environment variables""" 

15 self._api_key = os.getenv("DMXFY_API_KEY") 

16 

17 @property 

18 def api_key(self) -> str: 

19 """Get the API key""" 

20 if not self._api_key: 

21 raise ConfigurationError( 

22 "API key not found. Please set the DMXFY_API_KEY environment variable." 

23 ) 

24 return self._api_key 

25 

26 @property 

27 def headers(self) -> dict[str, str]: 

28 """Get the headers for API requests""" 

29 return { 

30 "Authorization": f"Bearer {self.api_key}", 

31 "Content-Type": "application/json", 

32 }