Commit Graph

8 Commits

Author SHA1 Message Date
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
Misaka_Company
e7bbbbc194 refactor(logging): Add optional logging support throughout codebase
Add centralized logging utility and optional logger parameters to all
core functions for better observability and debugging capabilities.

New modules:
- utils/logging.py: Centralized logger configuration with console
  and optional file handlers

Enhanced features:
- Added optional logger parameter to all extractor_core functions
- Added logger support to extractor, excel_converter, and auth modules
- Functions remain silent when logger=None (backward compatible)
- Improved environment variable validation in test files

Documentation:
- Added discrete_material_plan_extractor_core.md with complete API
  reference and usage patterns

Benefits:
- Consistent logging format across all components
- Optional debug output for troubleshooting
- No breaking changes - fully backward compatible
- Better error messages and validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 16:08:21 +08:00
Misaka_Company
c3bbc919a5 feat(extractor): Add Excel conversion and post-processing capabilities
Add comprehensive post-processing features to convert downloaded Excel files
into structured data and merge them into a single output file.

New modules:
- extractor_core.py: Stateless pure functions for web operations
- excel_converter.py: Excel to DataFrame conversion utility
- tests/test_extractor_real.py: Real data extraction test suite

Enhanced features:
- post_process_downloads(): Convert and merge multiple Excel files
- extract_and_process(): Complete workflow in single call
- cleanup_temp_files(): Optional cleanup of temporary downloaded files
- Field name mapping for standardized output columns

Dependencies:
- pandas>=2.0.0 for data manipulation
- openpyxl>=3.1.0 for Excel file handling

Documentation:
- Updated CLAUDE.md with new module references
- Added API documentation for extractor components

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 14:34:56 +08:00
Misaka_Company
1b984f5cfd refactor(extractor): Convert to stateless pure functions
- Remove DiscreteMaterialPlanExtractor class (stateful)
- Replace with pure functions: chunk_order_ids, get_login_url, extract_batch, etc.
- All functions are stateless, accept explicit parameters
- Caller manages browser/session lifecycle (consistent with extractor_core.py)
- Lower coupling: no direct dependency on utils.auth.login
- Update tests to match new function signatures

Breaking Changes:
- DiscreteMaterialPlanExtractor class removed
- Use extract_and_post_process() or extract_from_file() instead of class methods
- Caller must manage browser session before calling extractor functions
2026-03-27 13:52:13 +08:00
Misaka_Company
da567a2679 feat(extractor): Add DiscreteMaterialPlanExtractor class for batch data extraction
- Create DiscreteMaterialPlanExtractor class orchestrating web operations and post-processing
- Implement extract_and_process() combining download + Excel conversion
- Implement post_process_downloads() using ExcelConverter for merge
- Add extract_from_file() convenience function for file-based ID input
- Add component test file verifying class structure and methods
- Follow existing patterns: verbose logging, explicit parameters, English comments
2026-03-27 13:48:07 +08:00
Misaka_Company
8048f2e669 fix: add null safety check to URL construction in test_login.py
- Add explicit check for ERP_URL environment variable
- Prevent AttributeError when ERP_URL is not set
- Provide clear error message for missing configuration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 12:47:10 +08:00
Misaka_Company
fa33bee3e1 refactor: update test_login.py to use new auth API
- Import only login and logout (remove close_session)
- Add explicit URL construction before login call
- Pass all required parameters to login()
- Replace close_session() with direct context.close() and browser.close()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 12:45:56 +08:00
Misaka_Company
90e38821a5 Add Yonyou BIP automation framework with authentication
Features:
- Add auth module (utils/auth.py) for Yonyou BIP login/logout
- Add environment configuration support with python-dotenv
- Add Playwright browser automation with customizable path
- Add comprehensive test suite (tests/) with login/logout tests
- Add dependency management (requirements.txt)
- Add environment variable template (.env.example)

Key capabilities:
- Login with username/password from environment variables
- Auto-handle force login popup
- Logout with confirmation dialog handling
- Configurable headless mode and HTTPS error handling
- Auto-close browser option

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 11:11:15 +08:00