def test_process_file_no_scheme(caplog):
    """ Ensure that when process_file is called without a scheme and no 
        'HOST_BASE_PATH', 'CONTAINER_BASE_PATH' environment variables
        set, the appropriate error is raised."""

    filedata = {'url': 'www.foo.bar'}

    with pytest.raises(FileProtocolDisabled):
        process_file('upload', filedata)
def test_process_file_from_content(tmpdir, tmp_path):
    """ Ensure 'process_file' behaves correctly when the file contents
        should be drawn from the filedata content field."""

    test_file = tmpdir.join("testfile")
    filedata = {
        'path': str(tmp_path)  + '/testfile',
        'content': 'This is some test content'
    }
    process_file('inputs', filedata)

    assert open(str(tmp_path) + '/testfile', 'r').read() == filedata['content']
Exemple #3
0
    def test_upload_dir(self, copyMock, copyDirMock):
        filedata = {
            "url": "file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/",
            "path": "/TclSZU",
            "type": "DIRECTORY",
            "name": "workdir"
        }

        process_file('outputs', filedata)

        copyMock.assert_not_called()

        copyDirMock.assert_called_once_with('/TclSZU', '/transfer/tmphrtip1o8')
def test_process_file_with_scheme(mocker):
    """ Ensure expected behaviour when 'process_file' is called with scheme.
        In this test example, scheme is 'http', filedata:type is 'FILE' and
        ttype is 'inputs'."""

    filedata = {
        'url': 'http://www.foo.bar',
        'path': '.',
        'type': 'FILE',
    }
    mock_new_Trans = mocker.patch('tesk_core.filer.newTransput')
    process_file('inputs', filedata)

    mock_new_Trans.assert_called_once_with('http','www.foo.bar')
Exemple #5
0
    def test_upload_file(self, copyFileMock, copyDirMock):

        filedata = {
            "url": "file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5",
            "path": "/TclSZU/md5",
            "type": "FILE",
            "name": "stdout"
        }

        process_file('outputs', filedata)

        copyDirMock.assert_not_called()

        copyFileMock.assert_called_once_with('/TclSZU/md5',
                                             '/transfer/tmphrtip1o8/md5')
Exemple #6
0
    def test_download_file(self, copyMock, copyDirMock):
        filedata = {
            "url": "file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5",
            "path": "/var/lib/cwl/stgda974802-fa81-4f0b-8fe4-341d5655af4b/md5",
            "type": "FILE",  # File      = 'FILE'
            # Directory = 'DIRECTORY'
            "name": "md5",
            "description": "cwl_input:md5"
        }

        process_file('inputs', filedata)

        copyDirMock.assert_not_called()

        copyMock.assert_called_once_with(
            '/transfer/tmphrtip1o8/md5', '/var/lib/cwl/stgda974802-fa81-4f0b-'
            '8fe4-341d5655af4b/md5')