@@ -95,3 +95,84 @@ def test_not_implemented_methods(method_name):
9595 method = getattr (email , method_name )
9696 with pytest .raises (NotImplementedError ):
9797 method ()
98+
99+
100+ def test_preview_email_simple_html (tmp_path , snapshot ):
101+ html = "<html><body><p>Hello World!</p></body></html>"
102+ email = IntermediateEmail (
103+ html = html ,
104+ subject = "Simple Test Email" ,
105+ )
106+
107+ out_file = tmp_path / "preview.html"
108+ email .write_preview_email (str (out_file ))
109+ content = out_file .read_text (encoding = "utf-8" )
110+
111+ assert content == snapshot
112+
113+
114+ def test_preview_email_with_inline_attachments (tmp_path , snapshot ):
115+ html = """<html>
116+ <body>
117+ <h1>Email with Images</h1>
118+ <img src="cid:logo.png" alt="Logo" />
119+ <p>Some text content</p>
120+ <img src="cid:banner.jpg" alt="Banner" />
121+ </body>
122+ </html>"""
123+ email = IntermediateEmail (
124+ html = html ,
125+ subject = "Email with Inline Images" ,
126+ inline_attachments = {
127+ "logo.png" : "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" ,
128+ "banner.jpg" : "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCwAAA="
129+ },
130+ )
131+
132+ out_file = tmp_path / "preview.html"
133+ email .write_preview_email (str (out_file ))
134+ content = out_file .read_text (encoding = "utf-8" )
135+
136+ assert content == snapshot
137+
138+
139+ def test_preview_email_complex_html (tmp_path , snapshot ):
140+ html = """<!DOCTYPE html>
141+ <html lang="en">
142+ <head>
143+ <meta charset="UTF-8">
144+ <title>Test Email</title>
145+ <style>
146+ body { font-family: Arial, sans-serif; }
147+ .header { background-color: #f0f0f0; padding: 20px; }
148+ .content { padding: 20px; }
149+ </style>
150+ </head>
151+ <body>
152+ <div class="header">
153+ <h1>Welcome!</h1>
154+ </div>
155+ <div class="content">
156+ <p>This is a <strong>complex</strong> email with <em>formatting</em>.</p>
157+ <ul>
158+ <li>Item 1</li>
159+ <li>Item 2</li>
160+ <li>Item 3</li>
161+ </ul>
162+ <img src="cid:test.png" alt="Test Image" />
163+ </div>
164+ </body>
165+ </html>"""
166+ email = IntermediateEmail (
167+ html = html ,
168+ subject = "Complex Email Structure" ,
169+ inline_attachments = {
170+ "test.png" : "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
171+ },
172+ )
173+
174+ out_file = tmp_path / "preview.html"
175+ email .write_preview_email (str (out_file ))
176+ content = out_file .read_text (encoding = "utf-8" )
177+
178+ assert content == snapshot
0 commit comments