Example #1
0
def test_delete_remote_downloaded_file_no_server_section(context):
    context.driver_wrapper.config.remove_option('Server', 'enabled')
    response = mock.Mock()
    response.status_code.return_value = 200
    toolium.utils.download_files.requests.delete = mock.Mock(
        return_value=response)

    delete_remote_downloaded_file(context, "filename")
    toolium.utils.download_files.requests.delete.assert_not_called()
Example #2
0
def test_delete_remote_downloaded_file_server_section(context):
    context.driver_wrapper.config.set('Server', 'enabled', 'true')
    toolium.utils.download_files._get_download_directory_url = mock.Mock(
        return_value='https://host:8001')
    response_mock = mock.MagicMock()
    type(response_mock).status_code = mock.PropertyMock(return_value=200)
    toolium.utils.download_files.requests.delete = mock.Mock(
        return_value=response_mock)

    delete_remote_downloaded_file(context, "filename")
    toolium.utils.download_files.requests.delete.assert_called_once_with(
        'https://host:8001/filename')
Example #3
0
def test_delete_remote_downloaded_file_server_section_error(context):
    context.driver_wrapper.config.set('Server', 'enabled', 'true')
    toolium.utils.download_files._get_download_directory_url = mock.Mock(
        return_value='https://host:8001')
    response_mock = mock.MagicMock()
    type(response_mock).status_code = mock.PropertyMock(return_value=404)
    toolium.utils.download_files.requests.delete = mock.Mock(
        return_value=response_mock)

    with pytest.raises(AssertionError) as exc:
        delete_remote_downloaded_file(context, "filename")
    assert 'ERROR deleting file "https://host:8001/filename":' in str(
        exc.value)