Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/code-storage-python/pierre_storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ async def delete_git_credential(
url = f"{self.options['api_base_url']}/api/v{self.options['api_version']}/repos/git-credentials"

async with httpx.AsyncClient() as client:
response = await client.delete(
response = await client.request(
"DELETE",
url,
headers={
"Authorization": f"Bearer {jwt}",
Expand Down
15 changes: 8 additions & 7 deletions packages/code-storage-python/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,21 +784,22 @@ async def test_delete_git_credential(self, git_storage_options: dict) -> None:
mock_response.is_success = True

with patch("httpx.AsyncClient") as mock_client:
mock_delete = AsyncMock(return_value=mock_response)
mock_client.return_value.__aenter__.return_value.delete = mock_delete
mock_request = AsyncMock(return_value=mock_response)
mock_client.return_value.__aenter__.return_value.request = mock_request

result = await storage.delete_git_credential(id="cred-123")

assert result is None

# Verify the DELETE request was made to the correct URL
mock_delete.assert_called_once()
call_args = mock_delete.call_args[0]
api_url = call_args[0]
mock_request.assert_awaited_once()
call_args = mock_request.call_args[0]
assert call_args[0] == "DELETE"
api_url = call_args[1]
assert api_url == "https://api.test.code.storage/api/v1/repos/git-credentials"

# Verify the body
call_kwargs = mock_delete.call_args[1]
call_kwargs = mock_request.call_args[1]
body = call_kwargs["json"]
assert body["id"] == "cred-123"

Expand All @@ -812,7 +813,7 @@ async def test_delete_git_credential_not_found(self, git_storage_options: dict)
mock_response.is_success = False

with patch("httpx.AsyncClient") as mock_client:
mock_client.return_value.__aenter__.return_value.delete = AsyncMock(
mock_client.return_value.__aenter__.return_value.request = AsyncMock(
return_value=mock_response
)

Expand Down
Loading