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.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
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
|
||||
@@ -17,31 +18,40 @@ if not browser_path:
|
||||
raise ValueError("PLAYWRIGHT_BROWSERS_PATH environment variable is required")
|
||||
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = browser_path
|
||||
|
||||
print("=" * 50)
|
||||
print("ERP System Configuration Check")
|
||||
print("=" * 50)
|
||||
# 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
|
||||
print(f"Browser Path: {os.getenv('PLAYWRIGHT_BROWSERS_PATH')}")
|
||||
print(f"ERP URL: {os.getenv('ERP_URL')}")
|
||||
print(f"Username: {os.getenv('ERP_USERNAME')}")
|
||||
print(f"Password: {'*' * len(os.getenv('ERP_PASSWORD', ''))}")
|
||||
print(f"Headless Mode: {os.getenv('ERP_HEADLESS')}")
|
||||
print(f"Ignore HTTPS Errors: {os.getenv('ERP_IGNORE_HTTPS_ERRORS')}")
|
||||
print(f"Auto Close Browser: {os.getenv('ERP_AUTO_CLOSE_BROWSER')}")
|
||||
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')}")
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("Check Playwright Browser")
|
||||
print("=" * 50)
|
||||
logger.info("=" * 50)
|
||||
logger.info("Check Playwright Browser")
|
||||
logger.info("=" * 50)
|
||||
|
||||
with sync_playwright() as p:
|
||||
chromium_path = p.chromium.executable_path
|
||||
print(f"Chromium Path: {chromium_path}")
|
||||
logger.info(f"Chromium Path: {chromium_path}")
|
||||
|
||||
# Check if browser file exists
|
||||
if os.path.exists(chromium_path):
|
||||
print("[OK] Browser file exists")
|
||||
logger.info("Browser file exists")
|
||||
else:
|
||||
print("[ERROR] Browser file not found")
|
||||
logger.error("Browser file not found")
|
||||
|
||||
print("\n[OK] Configuration check completed!")
|
||||
logger.info("Configuration check completed!")
|
||||
|
||||
Reference in New Issue
Block a user