Skip to content

Fix Batch building bugs #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2025
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
2 changes: 1 addition & 1 deletion src/msgraph_core/requests/batch_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(
if request_adapter is None:
raise ValueError("request_adapter cannot be Null.")
self._request_adapter = request_adapter
self.url_template = f"{self._request_adapter.base_url}/$batch"
self.url_template = f"{self._request_adapter.base_url.removesuffix('/')}/$batch"
self.error_map = error_map or {}

async def post(
Expand Down
2 changes: 1 addition & 1 deletion src/msgraph_core/requests/batch_request_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def finalize(self):
Finalizes the batch request content.
"""
self.is_finalized = True
return self._requests
return self

def _request_by_id(self, request_id: str) -> Optional[BatchRequestItem]:
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/requests/test_batch_request_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def test_add_urllib_request(batch_request_content):


def test_finalize(batch_request_content):
finalized_requests = batch_request_content.finalize()
finalized_batch_request_content = batch_request_content.finalize()
assert batch_request_content.is_finalized
assert finalized_requests == batch_request_content.requests
assert finalized_batch_request_content.requests == batch_request_content.requests


def test_create_from_discriminator_value():
Expand Down