11. Reusable Utilities, Type-Safe Enums & Configuration Handlers

Enums & Config Models in Python

from enum import Enum

class Environment(str, Enum):
DEV = "https://dev.targetqa.com"
STAGING = "https://staging.targetqa.com"
PROD = "https://targetqa.com"

class BrowserType(str, Enum):
CHROME = "chrome"
FIREFOX = "firefox"
EDGE = "edge"

class TestConfig:
DEFAULT_TIMEOUT: int = 30
DEFAULT_ENV: Environment = Environment.STAGING

Task

  • Implement get_env_url(env_name: str) -> str:
  • 1. Accept env_name string.
  • 2. If env_name.lower() == "dev", return "https://dev.targetqa.com".
  • 3. If env_name.lower() == "staging", return "https://staging.targetqa.com".
  • 4. Default to "https://targetqa.com".
πŸ’‘Common doubts
Did you like the problem?
Lesson 11 of 37
Python
Loading code editor…
Next