Skip to content

Commit 6a6494c

Browse files
committed
update tests
Signed-off-by: gabriel miranda <gabrielmfern@outlook.com>
1 parent 3193350 commit 6a6494c

5 files changed

Lines changed: 75 additions & 0 deletions

File tree

tests/attachments_async_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ async def test_sent_email_attachments_list_async(self) -> None:
5656
"content_type": "image/png",
5757
"content_disposition": "inline",
5858
"size": 1024,
59+
"download_url": "https://cdn.resend.com/emails/test/attachments/test-id",
60+
"expires_at": "2025-10-17T14:29:41.521Z",
5961
}
6062
],
6163
}

tests/attachments_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ def test_receiving_list_attachments(self) -> None:
8686
"content_disposition": "inline",
8787
"content_id": "img001",
8888
"size": 1024,
89+
"download_url": "https://inbound-cdn.resend.com/test/attachments/2a0c9ce0?signature=sig-123",
90+
"expires_at": "2025-10-17T14:29:41.521Z",
8991
},
9092
{
9193
"id": "3b1d0df1-4223-5839-a87f-58eecd27b429",
9294
"filename": "document.pdf",
9395
"content_type": "application/pdf",
9496
"content_disposition": "attachment",
9597
"size": 2048,
98+
"download_url": "https://inbound-cdn.resend.com/test/attachments/3b1d0df1?signature=sig-456",
99+
"expires_at": "2025-10-17T14:29:41.521Z",
96100
},
97101
],
98102
}
@@ -110,6 +114,8 @@ def test_receiving_list_attachments(self) -> None:
110114
assert attachments["data"][0]["id"] == "2a0c9ce0-3112-4728-976e-47ddcd16a318"
111115
assert attachments["data"][0]["filename"] == "avatar.png"
112116
assert attachments["data"][0]["size"] == 1024
117+
assert "https://inbound-cdn.resend.com" in attachments["data"][0]["download_url"]
118+
assert attachments["data"][0]["expires_at"] == "2025-10-17T14:29:41.521Z"
113119
assert attachments["data"][1]["id"] == "3b1d0df1-4223-5839-a87f-58eecd27b429"
114120
assert attachments["data"][1]["filename"] == "document.pdf"
115121

@@ -125,6 +131,8 @@ def test_receiving_list_attachments_with_pagination(self) -> None:
125131
"content_type": "image/png",
126132
"content_disposition": "inline",
127133
"size": 1024,
134+
"download_url": "https://inbound-cdn.resend.com/test/attachments/2a0c9ce0?signature=sig-123",
135+
"expires_at": "2025-10-17T14:29:41.521Z",
128136
},
129137
],
130138
}

tests/emails_test.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def test_receiving_get(self) -> None:
280280
"content_type": "application/pdf",
281281
"content_id": "cid_123",
282282
"content_disposition": "attachment",
283+
"size": 4096,
283284
}
284285
],
285286
}
@@ -332,6 +333,61 @@ def test_receiving_get_with_no_attachments(self) -> None:
332333
assert email["reply_to"] is None
333334
assert len(email["attachments"]) == 0
334335

336+
def test_receiving_get_with_nullable_attachment_fields(self) -> None:
337+
# Inbound MIME parts (S/MIME signatures, calendar invites) can return
338+
# null for filename, content_id, and content_disposition.
339+
# See: https://linear.app/resend/issue/DEV-934
340+
self.set_mock_json(
341+
{
342+
"object": "inbound",
343+
"id": "67d9bcdb-5a02-42d7-8da9-0d6feea18cff",
344+
"to": ["received@example.com"],
345+
"from": "sender@example.com",
346+
"created_at": "2023-04-07T23:13:52.669661+00:00",
347+
"subject": "Signed inbound email",
348+
"html": None,
349+
"text": "hello world",
350+
"bcc": None,
351+
"cc": None,
352+
"reply_to": None,
353+
"headers": {},
354+
"message_id": "<msg@example.com>",
355+
"attachments": [
356+
{
357+
"id": "f5e32216-3017-4118-97d5-5c84d991bf98",
358+
"filename": "smime.p7s",
359+
"content_type": "application/pkcs7-signature",
360+
"content_id": None,
361+
"content_disposition": "attachment",
362+
"size": 1361,
363+
},
364+
{
365+
"id": "68136802-3577-4911-a7d2-b303e61261ac",
366+
"filename": None,
367+
"content_type": "text/calendar",
368+
"content_id": None,
369+
"content_disposition": None,
370+
"size": 1152,
371+
},
372+
],
373+
}
374+
)
375+
376+
email: resend.ReceivedEmail = resend.Emails.Receiving.get(
377+
email_id="67d9bcdb-5a02-42d7-8da9-0d6feea18cff",
378+
)
379+
assert len(email["attachments"]) == 2
380+
381+
smime = email["attachments"][0]
382+
assert smime["filename"] == "smime.p7s"
383+
assert smime["content_disposition"] == "attachment"
384+
assert smime["content_id"] is None
385+
386+
calendar = email["attachments"][1]
387+
assert calendar["filename"] is None
388+
assert calendar["content_disposition"] is None
389+
assert calendar["content_id"] is None
390+
335391
def test_should_receiving_get_raise_exception_when_no_content(self) -> None:
336392
self.set_mock_json(None)
337393
with self.assertRaises(NoContentError):

tests/receiving_async_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@ async def test_receiving_attachments_list_async(self) -> None:
117117
"content_disposition": "inline",
118118
"content_id": "img001",
119119
"size": 1024,
120+
"download_url": "https://inbound-cdn.resend.com/test/attachments/2a0c9ce0?signature=sig-123",
121+
"expires_at": "2025-10-17T14:29:41.521Z",
120122
},
121123
{
122124
"id": "3b1d0df1-4223-5839-a87f-58eecd27b429",
123125
"filename": "document.pdf",
124126
"content_type": "application/pdf",
125127
"content_disposition": "attachment",
126128
"size": 2048,
129+
"download_url": "https://inbound-cdn.resend.com/test/attachments/3b1d0df1?signature=sig-456",
130+
"expires_at": "2025-10-17T14:29:41.521Z",
127131
},
128132
],
129133
}

tests/response_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def test_list_response_supports_dict_access(self) -> None:
1818
"content_type": "image/png",
1919
"content_disposition": "inline",
2020
"size": 1024,
21+
"download_url": "https://cdn.resend.com/att-1",
22+
"expires_at": "2025-10-17T14:29:41.521Z",
2123
},
2224
],
2325
}
@@ -28,6 +30,7 @@ def test_list_response_supports_dict_access(self) -> None:
2830
assert attachments["has_more"] is False
2931
assert len(attachments["data"]) == 1
3032
assert attachments["data"][0]["id"] == "att-1"
33+
assert attachments["data"][0]["download_url"] == "https://cdn.resend.com/att-1"
3134

3235
def test_list_response_supports_attribute_access(self) -> None:
3336
self.set_mock_json(
@@ -41,6 +44,8 @@ def test_list_response_supports_attribute_access(self) -> None:
4144
"content_type": "image/png",
4245
"content_disposition": "inline",
4346
"size": 1024,
47+
"download_url": "https://cdn.resend.com/att-1",
48+
"expires_at": "2025-10-17T14:29:41.521Z",
4449
},
4550
],
4651
}

0 commit comments

Comments
 (0)