Beispiel #1
0
def test_did_downloader_is_downloading__lockfile_exists__pid_not_exists__should_return_false(
        mocker):
    mocker.patch.object(os.path, 'isfile', return_value=True)
    mocker.patch.object(psutil, 'pid_exists', return_value=False)

    with patch("builtins.open", mock_open(read_data="123")) as mock_file:
        result = DIDDownloader.is_downloading('/path')
        assert not result, 'Invalid return value'
        mock_file.assert_called_with(os.path.join('/path', '.lockfile'), 'r')
Beispiel #2
0
def test_did_downloader_is_downloading__lockfile_exists__pid_exists__process_running__status_zombie__should_return_false(
        mocker):
    mocker.patch.object(os.path, 'isfile', return_value=True)
    mocker.patch.object(psutil, 'pid_exists', return_value=True)

    class MockProcess:
        def __init__(self, pid):
            pass

        def is_running(self):  # pylint: disable=no-self-use
            return True

        def status(self):  # pylint: disable=no-self-use
            return 'zombie'

    mocker.patch('rucio_jupyterlab.mode_handlers.download.psutil.Process',
                 MockProcess)

    with patch("builtins.open", mock_open(read_data="123")) as mock_file:
        result = DIDDownloader.is_downloading('/path')
        assert not result, 'Invalid return value'
        mock_file.assert_called_with(os.path.join('/path', '.lockfile'), 'r')
Beispiel #3
0
def test_did_downloader_is_downloading__lockfile_not_exists__should_return_false(
        mocker):
    mocker.patch.object(os.path, 'isfile', return_value=False)
    result = DIDDownloader.is_downloading('/path')
    assert not result, 'Invalid return value'