Skip to content

Commit

Permalink
Unit test fixes I didn't catch
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Nov 2, 2023
1 parent 26b2ba6 commit 4869344
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions synapseclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,10 +1633,10 @@ def delete(self, obj, version=None):
delete.
"""
entity_id = id_of(obj)
trace.get_current_span().set_attributes({"synapse.id": entity_id})
# Handle all strings as the Entity ID for backward compatibility
if isinstance(obj, str):
entity_id = id_of(obj)
trace.get_current_span().set_attributes({"synapse.id": entity_id})
if version:
self.restDELETE(uri=f"/entity/{entity_id}/version/{version}")
else:
Expand Down
6 changes: 4 additions & 2 deletions synapseclient/core/upload/multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import mimetypes
import os
import re
import typing
import requests
import threading
import time
Expand Down Expand Up @@ -212,8 +213,9 @@ def _refresh_pre_signed_part_urls(

return refreshed_url

def _handle_part(self, part_number, otel_context: Context):
context.attach(otel_context)
def _handle_part(self, part_number, otel_context: typing.Union[Context, None]):
if otel_context:
context.attach(otel_context)
with tracer.start_as_current_span("UploadAttempt::_handle_part"):
with self._lock:
if self._aborted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_handle_part_aborted(self, syn):
upload._aborted = True

with pytest.raises(SynapseUploadAbortedException):
upload._handle_part(5)
upload._handle_part(5, None)

def test_handle_part__500(self, syn):
"""Test that we retry if we encounter a 500 from AWS on a PUT to the signed URL"""
Expand Down Expand Up @@ -323,7 +323,7 @@ def _handle_part_success_test(

mock_session.put.side_effect = [aws_call[1] for aws_call in aws_calls]

result = upload._handle_part(1)
result = upload._handle_part(1, None)

expected_put_calls = [aws_call[0] for aws_call in aws_calls]
assert mock_session.put.call_args_list == expected_put_calls
Expand Down Expand Up @@ -465,7 +465,7 @@ def test_handle_part__url_expired_twice(self, syn):
mock_session.put.return_value = mock_response

with pytest.raises(SynapseHTTPError):
upload._handle_part(1)
upload._handle_part(1, None)

def test_call_upload(self, syn):
"""Verify the behavior of an upload call, it should trigger
Expand Down

0 comments on commit 4869344

Please sign in to comment.