@@ -557,7 +557,7 @@ def test__process_response_bad_status(self):
557557 assert not upload .invalid
558558 response = _make_response (status_code = http_client .NOT_FOUND )
559559 with pytest .raises (common .InvalidResponse ) as exc_info :
560- upload ._process_response (response )
560+ upload ._process_response (response , None )
561561
562562 error = exc_info .value
563563 assert error .response is response
@@ -572,16 +572,20 @@ def test__process_response_success(self):
572572 upload = _upload .ResumableUpload (RESUMABLE_URL , ONE_MB )
573573 _fix_up_virtual (upload )
574574
575- total_bytes = 158
576- response_body = u'{{"size": "{:d}"}}' .format (total_bytes )
577- response_body = response_body .encode (u'utf-8' )
578- # Check status before.
575+ # Check / set status before.
579576 assert upload ._bytes_uploaded == 0
577+ upload ._bytes_uploaded = 20
580578 assert not upload ._finished
579+
580+ # Set the response body.
581+ bytes_sent = 158
582+ total_bytes = upload ._bytes_uploaded + bytes_sent
583+ response_body = u'{{"size": "{:d}"}}' .format (total_bytes )
584+ response_body = response_body .encode (u'utf-8' )
581585 response = mock .Mock (
582586 content = response_body , status_code = http_client .OK ,
583587 spec = [u'content' , u'status_code' ])
584- ret_val = upload ._process_response (response )
588+ ret_val = upload ._process_response (response , bytes_sent )
585589 assert ret_val is None
586590 # Check status after.
587591 assert upload ._bytes_uploaded == total_bytes
@@ -596,7 +600,7 @@ def test__process_response_partial_no_range(self):
596600 # Make sure the upload is valid before the failure.
597601 assert not upload .invalid
598602 with pytest .raises (common .InvalidResponse ) as exc_info :
599- upload ._process_response (response )
603+ upload ._process_response (response , None )
600604 # Make sure the upload is invalid after the failure.
601605 assert upload .invalid
602606
@@ -616,7 +620,7 @@ def test__process_response_partial_bad_range(self):
616620 response = _make_response (
617621 status_code = resumable_media .PERMANENT_REDIRECT , headers = headers )
618622 with pytest .raises (common .InvalidResponse ) as exc_info :
619- upload ._process_response (response )
623+ upload ._process_response (response , 81 )
620624
621625 # Check the error response.
622626 error = exc_info .value
@@ -635,7 +639,7 @@ def test__process_response_partial(self):
635639 headers = {u'range' : u'bytes=0-171' }
636640 response = _make_response (
637641 status_code = resumable_media .PERMANENT_REDIRECT , headers = headers )
638- ret_val = upload ._process_response (response )
642+ ret_val = upload ._process_response (response , 172 )
639643 assert ret_val is None
640644 # Check status after.
641645 assert upload ._bytes_uploaded == 172
@@ -932,14 +936,9 @@ def _get_headers(response):
932936 return response .headers
933937
934938
935- def _get_body (response ):
936- return response .content
937-
938-
939939def _fix_up_virtual (upload ):
940940 upload ._get_status_code = _get_status_code
941941 upload ._get_headers = _get_headers
942- upload ._get_body = _get_body
943942
944943
945944def _check_retry_strategy (upload ):
0 commit comments