diff --git a/gcloud/streaming/test_transfer.py b/gcloud/streaming/test_transfer.py index dfaa00be70cb..8ba3d02e227f 100644 --- a/gcloud/streaming/test_transfer.py +++ b/gcloud/streaming/test_transfer.py @@ -1429,7 +1429,7 @@ def test_stream_file_already_complete_w_seekable_stream_unsynced(self): with self.assertRaises(CommunicationError): upload.stream_file() - def test_stream_file_already_complete_w_seekable_stream_synced(self): + def test_stream_file_already_complete_wo_seekable_method_synced(self): import os from gcloud.streaming.transfer import RESUMABLE_UPLOAD CONTENT = b'ABCDEFGHIJ' @@ -1445,6 +1445,38 @@ def test_stream_file_already_complete_w_seekable_stream_synced(self): upload._complete = True self.assertTrue(upload.stream_file(use_chunks=False) is response) + def test_stream_file_already_complete_w_seekable_method_true_synced(self): + import os + from gcloud.streaming.transfer import RESUMABLE_UPLOAD + CONTENT = b'ABCDEFGHIJ' + http = object() + stream = _StreamWithSeekableMethod(CONTENT, True) + stream.seek(0, os.SEEK_END) + response = object() + upload = self._makeOne(stream, chunksize=1024) + upload.strategy = RESUMABLE_UPLOAD + upload._server_chunk_granularity = 128 + upload._initialize(http, _Request.URL) + upload._final_response = response + upload._complete = True + self.assertTrue(upload.stream_file(use_chunks=False) is response) + + def test_stream_file_already_complete_w_seekable_method_false(self): + import os + from gcloud.streaming.transfer import RESUMABLE_UPLOAD + CONTENT = b'ABCDEFGHIJ' + http = object() + stream = _StreamWithSeekableMethod(CONTENT, False) + stream.seek(0, os.SEEK_END) + response = object() + upload = self._makeOne(stream, chunksize=1024) + upload.strategy = RESUMABLE_UPLOAD + upload._server_chunk_granularity = 128 + upload._initialize(http, _Request.URL) + upload._final_response = response + upload._complete = True + self.assertTrue(upload.stream_file(use_chunks=False) is response) + def test_stream_file_incomplete(self): from six.moves import http_client from gcloud._testing import _Monkey @@ -1835,6 +1867,16 @@ def close(self): self._closed = True +class _StreamWithSeekableMethod(_Stream): + + def __init__(self, to_read=b'', seekable=True): + super(_StreamWithSeekableMethod, self).__init__(to_read) + self._seekable = seekable + + def seekable(self): + return self._seekable + + class _Request(object): __slots__ = ('url', 'http_method', 'body', 'headers', 'loggable_body') URL = 'http://example.com/api' diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index 6b77246d8bb5..11b36f90571b 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -66,7 +66,7 @@ } TEST_RC_REPLACEMENTS = { 'FORMAT': { - 'max-module-lines': 1900, + 'max-module-lines': 1950, }, }