Skip to content

Commit

Permalink
Fix and add test
Browse files Browse the repository at this point in the history
Now a different function is used in the code.
Also a couple of tests were added to increase coverage
  • Loading branch information
lvarin committed Jun 30, 2020
1 parent 61a5642 commit 89c4a92
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/test_filer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from tesk_core.filer import newTransput, FTPTransput, HTTPTransput, FileTransput,\
process_file, logConfig, getPath, copyDir
process_file, logConfig, getPath, copyDir, copyFile
from tesk_core.exception import UnknownProtocol, InvalidHostPath,\
FileProtocolDisabled
from tesk_core.path import containerPath
Expand Down Expand Up @@ -94,8 +94,8 @@ def test_upload_dir(self, copyMock, copyDirMock):
, '/transfer/tmphrtip1o8')

@patch('tesk_core.filer.copyDir')
@patch('tesk_core.filer.shutil.copy')
def test_upload_file(self, copyMock, copyDirMock):
@patch('tesk_core.filer.copyFile')
def test_upload_file(self, copyFileMock, copyDirMock):

filedata = {
"url": "file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5",
Expand All @@ -108,10 +108,29 @@ def test_upload_file(self, copyMock, copyDirMock):

copyDirMock.assert_not_called()

copyMock.assert_called_once_with( '/TclSZU/md5'
copyFileMock.assert_called_once_with( '/TclSZU/md5'
, '/transfer/tmphrtip1o8/md5')


@patch('tesk_core.filer.copyDir')
@patch('tesk_core.filer.copyFile')
def test_upload_file_glob(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*')


def test_copyDir(self):

def rmDir(d):
Expand Down Expand Up @@ -170,6 +189,11 @@ def test_getPath(self):
self.assertEquals( getPath('file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5')
, '/home/tfga/workspace/cwl-tes/tmphrtip1o8/md5')

def test_getPathNoScheme(self):

self.assertEquals( getPath('/home/tfga/workspace/cwl-tes/tmphrtip1o8/md5')
, '/home/tfga/workspace/cwl-tes/tmphrtip1o8/md5')


def test_containerPath(self):

Expand Down

0 comments on commit 89c4a92

Please sign in to comment.