Пример #1
0
def test_GirderFileStreamReader_returns_bytes_on_stop_iteration():
    mock_gc = mock.MagicMock(spec=GirderClient)

    # Note: this is only nessisary until 2eb72df is released in girder-client
    mock_gc.downloadFileAsIterator = mock.MagicMock()

    mock_gc.downloadFileAsIterator.return_value = itertools.chain([])

    gfsr = GirderFileStreamReader(mock_gc, -1)
    for b in gfsr.read(65536):
        assert type(b, bytes)
Пример #2
0
def test_GirderFileStreamReader_calls_girder_client_downloadFileAsIterator():
    mock_gc = mock.MagicMock(spec=GirderClient)

    # Note: this is only nessisary until 2eb72df is released in girder-client
    mock_gc.downloadFileAsIterator = mock.MagicMock()

    mock_gc.downloadFileAsIterator.return_value = itertools.chain([b'1', b'2', b'3'])

    gfsr = GirderFileStreamReader(mock_gc, -1)
    gfsr.read(65536)
    mock_gc.downloadFileAsIterator.assert_any_call(-1, 65536)
Пример #3
0
 def transform(self, **kwargs):
     from girder_worker.docker.io.girder import (GirderFileStreamReader)
     return GirderFileStreamReader(self.gc, self.file_id)