Files
BIPAuto/tests/test_auth_config.py
Misaka_Company 440b74d09a test(logging): unify test file logging to standard logging module
- Replace print() statements with logging module in all test files
- Use consistent logger naming: bipauto.tests.<test_name>
- Apply unified log format: [%(levelname)s] %(name)s: %(message)s
- Migrates test_extractor_real.py, test_login.py, test_auth_config.py, test_extractor_component.py

This change ensures consistent log output format between test files and utils modules, matching the existing bipauto.* logger hierarchy.
2026-03-27 16:28:00 +08:00

58 lines
1.8 KiB
Python

"""
Test if auth module configuration is correct
"""
import logging
from playwright.sync_api import sync_playwright
from dotenv import load_dotenv
from pathlib import Path
import os
# Load environment variables
PROJECT_ROOT = Path(__file__).resolve().parent.parent
load_dotenv(PROJECT_ROOT / ".env")
# Configure browser path
browser_path = os.getenv("PLAYWRIGHT_BROWSERS_PATH")
if not browser_path:
raise ValueError("PLAYWRIGHT_BROWSERS_PATH environment variable is required")
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = browser_path
# Setup logging
logger = logging.getLogger('bipauto.tests.auth_config')
logger.setLevel(logging.INFO)
if not logger.handlers:
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("[%(levelname)s] %(name)s: %(message)s"))
logger.addHandler(handler)
logger.propagate = False
logger.info("=" * 50)
logger.info("ERP System Configuration Check")
logger.info("=" * 50)
# Display configuration information
logger.info(f"Browser Path: {os.getenv('PLAYWRIGHT_BROWSERS_PATH')}")
logger.info(f"ERP URL: {os.getenv('ERP_URL')}")
logger.info(f"Username: {os.getenv('ERP_USERNAME')}")
logger.info(f"Password: {'*' * len(os.getenv('ERP_PASSWORD', ''))}")
logger.info(f"Headless Mode: {os.getenv('ERP_HEADLESS')}")
logger.info(f"Ignore HTTPS Errors: {os.getenv('ERP_IGNORE_HTTPS_ERRORS')}")
logger.info(f"Auto Close Browser: {os.getenv('ERP_AUTO_CLOSE_BROWSER')}")
logger.info("=" * 50)
logger.info("Check Playwright Browser")
logger.info("=" * 50)
with sync_playwright() as p:
chromium_path = p.chromium.executable_path
logger.info(f"Chromium Path: {chromium_path}")
# Check if browser file exists
if os.path.exists(chromium_path):
logger.info("Browser file exists")
else:
logger.error("Browser file not found")
logger.info("Configuration check completed!")