File size: 3,411 Bytes
ab028ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/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()