Skip to content

Commit

Permalink
NXDRIVE-2711: Show that upload is still alive for very large files
Browse files Browse the repository at this point in the history
  • Loading branch information
swetayadav1 committed Oct 17, 2023
1 parent 2968e81 commit 7a400a7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
3 changes: 1 addition & 2 deletions nxdrive/gui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ def data(self, index: QModelIndex, role: int, /) -> Any:
if role == self.TRANSFERRED:
return self.psize(row["filesize"] * row["progress"] / 100)
if role == self.FINALIZING_STATUS:
a = row.get("finalizing_status")
return a
return row.get("finalizing_status")
return row[self.names[role].decode()]

def setData(self, index: QModelIndex, value: Any, /, *, role: int = None) -> None:
Expand Down
10 changes: 0 additions & 10 deletions tests/functional/test_view.py

This file was deleted.

34 changes: 33 additions & 1 deletion tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import time
from typing import Optional
from typing import Any, Callable, Optional
from uuid import uuid4

import pytest
Expand All @@ -13,9 +13,12 @@
from nxdrive.dao.manager import ManagerDAO
from nxdrive.engine.engine import Engine
from nxdrive.engine.processor import Processor
from nxdrive.gui.view import DirectTransferModel
from nxdrive.manager import Manager
from nxdrive.objects import DocPair, Upload
from nxdrive.osi import AbstractOSIntegration
from nxdrive.qt import constants as qt
from nxdrive.qt.imports import QObject
from nxdrive.updater.darwin import Updater
from nxdrive.utils import normalized_path

Expand Down Expand Up @@ -148,6 +151,13 @@ def __init__(self, Remote):
super().__init__(self, Remote)


class MockDirectTransferModel(DirectTransferModel):
def __init__(
self, translate: Callable[..., Any], /, *, parent: QObject = None
) -> None:
super().__init__(translate, parent=parent)


@pytest.fixture()
def engine_dao(tmp_path):
dao = MockEngineDAO
Expand Down Expand Up @@ -219,3 +229,25 @@ def upload():
upload.doc_pair = "test_file"
upload.request_uid = str(uuid4())
return upload


@pytest.fixture()
def direct_transfer_model():
direct_transfer_model = MockDirectTransferModel
direct_transfer_model.FINALIZING_STATUS = qt.UserRole + 13
direct_transfer_model.items = [
{
"uid": 1,
"name": "a.txt",
"filesize": 142936511610,
"status": "",
"engine": "51a2c2dc641311ee87fb...bfc0ec09fa",
"progress": 100.0,
"doc_pair": 1,
"remote_parent_path": "/default-domain/User...TestFolder",
"remote_parent_ref": "7b7886ea-5ad9-460d-8...1607ea0081",
"shadow": True,
"finalizing": True,
}
]
return direct_transfer_model
1 change: 1 addition & 0 deletions tests/unit/test_client_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


def test_link_blob_to_doc(baseuploader, upload, tmp_path):
"""Test link blob to document functionality"""
file = tmp_path / f"{uuid4()}.txt"
file.write_bytes(b"content")

Expand Down
27 changes: 27 additions & 0 deletions tests/unit/test_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from unittest.mock import Mock

from nxdrive.gui.view import FileModel


def test_foldersDialog():
def func():
return True

file_model = FileModel(func)
returned_val = file_model.add_files([{"key": "val"}])
assert not returned_val


def test_set_progress(direct_transfer_model):
"""Test the finalize state after 100% progress"""
action = {
"engine": "51a2c2dc641311ee87fb...bfc0ec09fa",
"doc_pair": 1,
"progress": "100",
"action_type": "Linking",
"finalizing_status": "Finalize the status",
}

direct_transfer_model.createIndex = Mock(return_value=1)
direct_transfer_model.setData = Mock()
direct_transfer_model.set_progress(direct_transfer_model, action)

0 comments on commit 7a400a7

Please sign in to comment.