@@ -155,6 +155,46 @@ def test_list_email_messages_success(self, mock_request):
155155 ],
156156 )
157157
158+ @patch ("tempmail.client.requests.Session.request" )
159+ def test_list_email_messages_no_attachments (self , mock_request ):
160+ mock_response = Mock ()
161+ mock_response .status_code = 200
162+ mock_response .json .return_value = {
163+ "messages" : [
164+ {
165+ "id" : "msg1" ,
166+ "from" : "sender@example.com" ,
167+ "to" : "test@temp.io" ,
168+ "cc" : ["cc@example.com" ],
169+ "subject" : "Test Subject" ,
170+ "body_text" : "Test body" ,
171+ "body_html" : "<p>Test body</p>" ,
172+ "created_at" : "2023-01-01T00:00:00Z" ,
173+ "attachments" : None ,
174+ }
175+ ]
176+ }
177+ mock_response .headers = self ._rate_limit_headers
178+ mock_request .return_value = mock_response
179+
180+ client = TempMailClient ("test-api-key" )
181+ messages : typing .List [EmailMessage ] = client .list_email_messages ("test@temp.io" )
182+
183+ assert len (messages ) == 1
184+ assert messages [0 ] == EmailMessage (
185+ id = "msg1" ,
186+ from_addr = "sender@example.com" ,
187+ to_addr = "test@temp.io" ,
188+ cc = ["cc@example.com" ],
189+ subject = "Test Subject" ,
190+ body_text = "Test body" ,
191+ body_html = "<p>Test body</p>" ,
192+ created_at = datetime .datetime (
193+ 2023 , 1 , 1 , 0 , 0 , tzinfo = datetime .timezone .utc
194+ ),
195+ attachments = [],
196+ )
197+
158198 @patch ("tempmail.client.requests.Session.request" )
159199 def test_list_email_messages_empty (self , mock_request ):
160200 mock_response = Mock ()
0 commit comments