import os import sys # Ensure we can import from the current directory sys.path.append(os.getcwd()) import config from services.invoice_service import InvoiceService # Mock order data order_data = { 'id': 999, 'first_name': 'Test', 'last_name': 'User', 'total_price': 100.0, 'is_company': False, 'shipping_address': 'Test Address 123' } print("--- START TEST GENERATION ---") try: path = InvoiceService.generate_document(order_data, doc_type="faktura") print(f"SUCCESS! Service returned path: {path}") # Check if file exists physically abs_path = os.path.abspath(os.path.join(config.UPLOAD_DIR, "invoices", "faktura_order_999.pdf")) if os.path.exists(abs_path): print(f"CONFIRMED: File exists at {abs_path}") else: print(f"FAIL: File NOT FOUND at {abs_path}") # Let's see what IS in the upload dir print(f"Contents of {config.UPLOAD_DIR}: {os.listdir(config.UPLOAD_DIR) if os.path.exists(config.UPLOAD_DIR) else 'DIR NOT FOUND'}") except Exception as e: print(f"CRASH: {e}") import traceback traceback.print_exc() print("--- END TEST GENERATION ---")