Spaces:
Configuration error
Configuration error
| #!/usr/bin/env python3 | |
| """ | |
| Test script for PDF generation using xhtml2pdf. | |
| """ | |
| from pdf_generator import create_pdf_resume | |
| from utils import log_info | |
| # Test data | |
| test_data = { | |
| 'name': 'John Doe', | |
| 'email': 'john.doe@example.com', | |
| 'phone': '+1 (555) 123-4567', | |
| 'linkedin': 'johndoe', | |
| 'github': 'johndoe', | |
| 'website': 'https://johndoe.com', | |
| 'summary': 'Experienced software developer with 5+ years of expertise in full-stack development, cloud technologies, and team leadership. Passionate about building scalable solutions and mentoring junior developers.', | |
| 'work_experience': [ | |
| { | |
| 'title': 'Senior Software Engineer', | |
| 'organization': 'Tech Corp', | |
| 'start_date': 'Jan 2022', | |
| 'end_date': 'Present', | |
| 'remarks': 'Leading development of microservices architecture serving 1M+ users. Mentoring team of 5 developers.' | |
| }, | |
| { | |
| 'title': 'Software Developer', | |
| 'organization': 'StartupXYZ', | |
| 'start_date': 'Jun 2020', | |
| 'end_date': 'Dec 2021', | |
| 'remarks': 'Developed RESTful APIs and implemented CI/CD pipelines. Reduced deployment time by 60%.' | |
| } | |
| ], | |
| 'projects': [ | |
| { | |
| 'title': 'E-commerce Platform', | |
| 'organization': 'Personal Project', | |
| 'start_date': 'Mar 2023', | |
| 'end_date': 'May 2023', | |
| 'remarks': 'Built full-stack e-commerce platform using React, Node.js, and PostgreSQL. Implemented payment processing and inventory management.' | |
| } | |
| ], | |
| 'education': [ | |
| { | |
| 'title': 'Bachelor of Science in Computer Science', | |
| 'organization': 'University of Technology', | |
| 'start_date': 'Sep 2016', | |
| 'end_date': 'May 2020', | |
| 'remarks': 'Graduated Magna Cum Laude. President of Computer Science Club.' | |
| } | |
| ], | |
| 'skills': 'Python, JavaScript, React, Node.js, PostgreSQL, MongoDB, AWS, Docker, Kubernetes, Git, CI/CD', | |
| 'achievements': 'Employee of the Year 2023, Best Project Award at University Hackathon 2019', | |
| 'sections_order': ['work_experience', 'projects', 'education', 'skills', 'achievements'] | |
| } | |
| def test_pdf_generation(): | |
| """Test PDF generation for both templates.""" | |
| try: | |
| log_info("Testing PDF generation...") | |
| # Test standard template | |
| log_info("Generating standard template PDF...") | |
| pdf_bytes_standard = create_pdf_resume(test_data, "standard") | |
| if pdf_bytes_standard: | |
| with open('test_resume_standard.pdf', 'wb') as f: | |
| f.write(pdf_bytes_standard) | |
| log_info("Standard PDF generated successfully: test_resume_standard.pdf") | |
| else: | |
| log_info("Failed to generate standard PDF") | |
| # Test modern template | |
| log_info("Generating modern template PDF...") | |
| pdf_bytes_modern = create_pdf_resume(test_data, "modern") | |
| if pdf_bytes_modern: | |
| with open('test_resume_modern.pdf', 'wb') as f: | |
| f.write(pdf_bytes_modern) | |
| log_info("Modern PDF generated successfully: test_resume_modern.pdf") | |
| else: | |
| log_info("Failed to generate modern PDF") | |
| except Exception as e: | |
| log_error(f"Test failed: {str(e)}", e) | |
| if __name__ == "__main__": | |
| test_pdf_generation() |