Initial commit: Pokemon Discovery - TCG product scraper and PDF catalog generator
- Comprehensive scraper for Dollar General Pokemon TCG products - Professional PDF catalog generator with UPC-A barcodes - Robust anti-bot handling with requests + Selenium fallback - Automatic image downloading and barcode generation - Unix-friendly timestamped filenames - Virtual environment support and dependency management - Complete documentation and usage guides
This commit is contained in:
55
test_barcode.py
Normal file
55
test_barcode.py
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify barcode generation functionality
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Add current directory to path if running in venv
|
||||
sys.path.insert(0, '.')
|
||||
|
||||
try:
|
||||
import barcode
|
||||
from barcode.writer import ImageWriter
|
||||
print("✓ Barcode generation libraries are available")
|
||||
|
||||
# Test barcode generation
|
||||
test_sku = "123456789012"
|
||||
|
||||
upc_generator = barcode.get_barcode_class('upca')
|
||||
test_barcode = upc_generator("12345678901", writer=ImageWriter())
|
||||
|
||||
# Create test output directory
|
||||
test_dir = Path("test_output")
|
||||
test_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Generate test barcode
|
||||
barcode_path = test_dir / "test_barcode"
|
||||
test_barcode.save(str(barcode_path), options={
|
||||
'module_width': 0.2,
|
||||
'module_height': 15.0,
|
||||
'quiet_zone': 6.5,
|
||||
'font_size': 10,
|
||||
'text_distance': 5.0,
|
||||
'background': 'white',
|
||||
'foreground': 'black'
|
||||
})
|
||||
|
||||
final_path = f"{barcode_path}.png"
|
||||
if os.path.exists(final_path):
|
||||
print(f"✓ Test barcode generated successfully: {final_path}")
|
||||
print(f" File size: {os.path.getsize(final_path)} bytes")
|
||||
else:
|
||||
print(f"✗ Failed to generate test barcode")
|
||||
sys.exit(1)
|
||||
|
||||
except ImportError as e:
|
||||
print(f"✗ Missing barcode library: {e}")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"✗ Barcode generation failed: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
print("✓ All barcode generation tests passed!")
|
||||
Reference in New Issue
Block a user