Skip to content

Commit 96e8f9b

Browse files
committed
fix: pass data in non-multipart requests and tighten error assertions in tests
1 parent a386f62 commit 96e8f9b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

resend/http_client_httpx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def request(
3838
url=url,
3939
headers=headers,
4040
json=json,
41+
data=data,
4142
)
4243
return resp.content, resp.status_code, resp.headers
4344
except httpx.RequestError as e:

resend/http_client_requests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def request(
3838
url=url,
3939
headers=headers,
4040
json=json,
41+
data=data,
4142
timeout=self._timeout,
4243
)
4344
return resp.content, resp.status_code, resp.headers

tests/contact_imports_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ def test_create_contact_import_with_options(self) -> None:
3333
assert resp["id"] == "479e3145-dd38-476b-932c-529ceb705947"
3434

3535
def test_create_contact_import_missing_file(self) -> None:
36-
try:
36+
with self.assertRaises(ValueError) as ctx:
3737
resend.Contacts.Imports.create({"file": b""})
38-
except ValueError as e:
39-
assert str(e) == "file is required"
38+
assert str(ctx.exception) == "file is required"
4039

4140
def test_get_contact_import(self) -> None:
4241
self.set_mock_json(
@@ -65,10 +64,9 @@ def test_get_contact_import(self) -> None:
6564
assert counts["total"] == 100
6665

6766
def test_get_contact_import_missing_id(self) -> None:
68-
try:
67+
with self.assertRaises(ValueError) as ctx:
6968
resend.Contacts.Imports.get("")
70-
except ValueError as e:
71-
assert str(e) == "id is required"
69+
assert str(ctx.exception) == "id is required"
7270

7371
def test_list_contact_imports(self) -> None:
7472
self.set_mock_json(

0 commit comments

Comments
 (0)