def test_ChunkedTransferEncodingStream_transform_returns_ChunkedTransferEncodingStreamWriter(
):
    ctes = ChunkedTransferEncodingStream('http://bogusurl.com')
    with mock.patch('girder_worker.docker.io.httplib.HTTPConnection',
                    autospec=True):
        assert isinstance(ctes.transform(),
                          ChunkedTransferEncodingStreamWriter)
def test_ChunkedTransferEncodingStream_transform_calls_ChunkedTransferEncodingWriter_with_args(
):
    ctes = ChunkedTransferEncodingStream('http://bogusurl.com')
    with mock.patch(
            'girder_worker.docker.io.ChunkedTransferEncodingStreamWriter',
            spec=True) as ctesw_class_mock:
        ctes.transform()
        ctesw_class_mock.assert_called_once_with('http://bogusurl.com', {})
Beispiel #3
0
    def test_docker_run_transfer_encoding_stream(self, params):
        item_id = params.get('itemId')
        file_id = params.get('fileId')
        delimiter = params.get('delimiter')

        headers = {
            'Girder-Token': str(Token().createToken(getCurrentUser())['_id'])
        }
        url = '%s/%s?itemId=%s&delimiter=%s' % (
            getApiUrl(), 'integration_tests/docker/input_stream', item_id, delimiter)

        container_args = [
            'read_write',
            '-i', GirderFileIdToVolume(file_id),
            '-o', Connect(NamedOutputPipe('out'),
                          ChunkedTransferEncodingStream(url, headers))
        ]
        result = docker_run.delay(
            TEST_IMAGE, pull_image=True, container_args=container_args,
            remove_container=True)

        return result.job