From 730be92a3dd1f5cc6d9df0c3533140c75dbaf046 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 22 Mar 2026 21:59:13 +0000 Subject: [PATCH] Add mockapi source files and tests --- src/mockapi/core/config.py | 42 ++++++-------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/src/mockapi/core/config.py b/src/mockapi/core/config.py index 4ae41ec..f3c479f 100644 --- a/src/mockapi/core/config.py +++ b/src/mockapi/core/config.py @@ -22,19 +22,11 @@ class Config: strict_validation: bool = False error_probability: float = 0.0 error_code: int = 500 - config_path: Optional[str] = None @classmethod def load(cls, config_path: Optional[str] = None) -> "Config": - """Load configuration from file and environment. - - Args: - config_path: Path to mockapi.yaml config file - - Returns: - Config instance with loaded values - """ + """Load configuration from file and environment.""" config = cls() if config_path: @@ -62,11 +54,7 @@ class Config: @classmethod def _load_from_env(cls) -> Dict[str, Any]: - """Load configuration from environment variables. - - Returns: - Dictionary of configuration values - """ + """Load configuration from environment variables.""" config = {} if port := os.environ.get("MOCKAPI_PORT"): @@ -88,14 +76,7 @@ class Config: @classmethod def _load_from_file(cls, config_path: str) -> Dict[str, Any]: - """Load configuration from YAML file. - - Args: - config_path: Path to the config file - - Returns: - Dictionary of configuration values - """ + """Load configuration from YAML file.""" try: with open(config_path, "r") as f: data = yaml.safe_load(f) or {} @@ -129,11 +110,7 @@ class Config: return {} def to_dict(self) -> Dict[str, Any]: - """Convert config to dictionary. - - Returns: - Dictionary representation of config - """ + """Convert config to dictionary.""" return { "port": self.port, "host": self.host, @@ -149,12 +126,5 @@ class Config: def load_config(config_path: Optional[str] = None) -> Config: - """Load configuration from file and environment. - - Args: - config_path: Optional path to config file - - Returns: - Config instance - """ - return Config.load(config_path) \ No newline at end of file + """Load configuration from file and environment.""" + return Config.load(config_path)