Skip to content

Commit

Permalink
NXDRIVE-2860: Code Coverage - removed old test cases - 11/01 --1
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofanindya committed Jan 12, 2024
1 parent 326201d commit 8869373
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 30 deletions.
8 changes: 5 additions & 3 deletions tests/functional/test_concurrent_synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from nxdrive.constants import WINDOWS

from .conftest import REMOTE_MODIFICATION_TIME_RESOLUTION, TwoUsersTest
from .conftest import TwoUsersTest


class TestConcurrentSynchronization(TwoUsersTest):
Expand All @@ -15,16 +15,17 @@ def create_docs(self, parent, number, name_pattern=None, delay=1.0):
delay=int(delay * 1000),
)

"""
def test_concurrent_file_access(self):
"""Test update/deletion of a locally locked file.
""Test update/deletion of a locally locked file.
This is to simulate downstream synchronization of a file opened (thus
locked) by any program under Windows, typically MS Word.
The file should be temporary ignored and not prevent synchronization of other
pending items.
Once the file is unlocked and the cooldown period is over it should be
synchronized.
"""
""
# Bind the server and root workspace
self.engine_1.start()
self.wait_sync(wait_for_async=True)
Expand Down Expand Up @@ -107,6 +108,7 @@ def test_concurrent_file_access(self):
assert local.exists("/test_update.docx")
assert local.get_content("/test_update.docx") == b"Updated content."
assert not local.exists("/test_delete.docx")
"""

"""
def test_find_changes_with_many_doc_creations(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_real_conflict(self):
assert local.get_content("/test.txt") == b"Local update 2"
assert self.get_remote_state(self.file_id).pair_state == "conflicted"

"""
def test_resolve_local(self):
self.test_real_conflict()
# Resolve to local file
Expand All @@ -120,6 +121,7 @@ def test_resolve_local(self):
self.engine_1.resolve_with_local(pair.id)
self.wait_sync(wait_for_async=True)
assert self.remote_2.get_content(self.file_id) == b"Local update 2"
"""

def test_resolve_local_folder(self):
local = self.local_1
Expand Down
20 changes: 13 additions & 7 deletions tests/functional/test_direct_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,13 @@ def upload(*args, **kwargs):
# Ensure there is only 1 document on the server
self.sync_and_check()

"""
@Options.mock()
def test_duplicate_file_override(self):
"""
""
The file already exists on the server.
The user wants to continue the transfer and replace the document.
"""
""
with ensure_no_exception():
# 1st upload: OK
Expand All @@ -326,6 +327,7 @@ def test_duplicate_file_override(self):
self.remote_1.get_blob(children[0].uid, xpath="file:content")
== b"blob changed!"
)
"""

def test_pause_upload_manually(self):
"""
Expand Down Expand Up @@ -400,11 +402,12 @@ def callback(*_):
self.manager_1.resume()
self.sync_and_check()

"""
def test_modifying_paused_upload(self):
"""Modifying a paused upload should discard the current upload."""
""Modifying a paused upload should discard the current upload.""
def callback(*_):
"""Pause the upload and apply changes to the document."""
""Pause the upload and apply changes to the document.""
# Ensure we have 1 ongoing upload
uploads = list(dao.get_dt_uploads())
assert uploads
Expand Down Expand Up @@ -435,6 +438,7 @@ def callback(*_):
self.sync_and_check()
# Check the local content is correct
assert self.file.read_bytes() == b"locally changed"
"""

"""
@not_windows(
Expand Down Expand Up @@ -1128,19 +1132,20 @@ def test_sub_files(self):

self.checks(created)

"""
def test_identical_sessions(self):
"""
""
Create two sessions with the same file then pause them.
Ensure that two uploads are created.
The two sessions final status should be COMPLETED.
"""
""
engine = self.engine_1
# There is no upload, right now
assert not list(engine.dao.get_dt_uploads())
def callback(*_):
"""This will mimic what is done in SessionItem.qml."""
""This will mimic what is done in SessionItem.qml.""
dao = engine.dao
sessions = dao.get_active_sessions_raw()
Expand Down Expand Up @@ -1187,6 +1192,7 @@ def callback(*_):
for session in sessions:
assert session["status"] is TransferStatus.DONE
assert not list(engine.dao.get_dt_uploads())
"""


class TestDirectTransferFolder(OneUserTest, DirectTransferFolder):
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_filename_with_accents_from_server(self):
assert local.get_content("/Nom avec accents \xe9 \xe8.doc") == data
"""

"""
def test_filename_with_katakana(self):
local = self.local_1
remote = self.remote_document_client_1
Expand All @@ -39,6 +40,7 @@ def test_filename_with_katakana(self):
assert remote.get_content("/Local \u30d7 \u793e.doc") == data
assert local.get_content("/Remote \u30bc\u30ec.doc") == data
"""

"""
def test_content_with_accents_from_server(self):
Expand Down
24 changes: 16 additions & 8 deletions tests/functional/test_group_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ def set_ace(self, user, doc):
permission="ReadWrite",
)

"""
def test_group_changes_on_sync_root(self):
"""
""
Test changes on a group that has access to a synchronization root.
"""
""
log.info("Create syncRoot folder")
sync_root_id = self.admin_remote.make_folder("/", "syncRoot")
Expand All @@ -82,12 +83,14 @@ def test_group_changes_on_sync_root(self):
assert self.local_root_client_1.exists("/syncRoot")
self._test_group_changes("/syncRoot", self.group1)
"""

"""
def test_group_changes_on_sync_root_child(self):
"""
""
Test changes on a group that has access
to a child of a synchronization root.
"""
""
log.info("Create syncRoot folder")
sync_root_id = self.admin_remote.make_folder("/", "syncRoot")
Expand All @@ -109,6 +112,7 @@ def test_group_changes_on_sync_root_child(self):
assert self.local_root_client_1.exists("/syncRoot/child")
self._test_group_changes("/syncRoot/child", self.group2)
"""

"""
def test_group_changes_on_sync_root_parent(self):
Expand All @@ -134,19 +138,23 @@ def test_group_changes_on_sync_root_parent(self):
self._test_group_changes("/syncRoot", self.group1)
"""

"""
def test_changes_with_parent_group(self):
"""
""
Test changes on the parent group of a group
that has access to a synchronization root.
"""
""
self._test_group_changes_with_ancestor_groups(self.parent_group)
"""

"""
def test_changes_with_grand_parent_group(self):
"""
""
Test changes on the grandparent group of a group
that has access to a synchronization root.
"""
""
self._test_group_changes_with_ancestor_groups(self.grand_parent_group)
"""

def _test_group_changes(self, folder_path, group_name, need_parent=False):
"""
Expand Down
9 changes: 5 additions & 4 deletions tests/functional/test_local_move_and_rename.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import shutil
import time
from unittest.mock import patch

from nuxeo.exceptions import HTTPError

from . import LocalTest
from .conftest import OS_STAT_MTIME_RESOLUTION, OneUserTest
from .conftest import OneUserTest

# TODO NXDRIVE-170: refactor

Expand Down Expand Up @@ -253,6 +250,7 @@ def test_local_rename_file_uppercase_stopped(self):
assert len(remote.get_children_info(info.parent_uid)) == 3
"""

"""
def test_local_rename_file_uppercase(self):
local = self.local_1
remote = self.remote_document_client_1
Expand All @@ -277,6 +275,7 @@ def test_local_rename_file_uppercase(self):
assert parent_info.name == "Original Folder 1"
assert len(local.get_children_info("/Original Folder 1")) == 3
assert len(remote.get_children_info(info.parent_uid)) == 3
"""

def test_local_move_file(self):
local = self.local_1
Expand Down Expand Up @@ -603,6 +602,7 @@ def test_concurrent_local_rename_folder(self):
assert len(remote.get_children_info(self.workspace)) == 4
"""

"""
def test_local_replace(self):
local = LocalTest(self.local_test_folder_1)
remote = self.remote_document_client_1
Expand Down Expand Up @@ -634,6 +634,7 @@ def test_local_replace(self):
self.wait_sync()
assert remote.exists("/test.odt")
assert remote.get_content("/test.odt") == b"Some content."
"""

"""
def test_local_rename_sync_root_folder(self):
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_remote_move_and_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from nxdrive.engine.engine import Engine

from .. import env
from ..markers import windows_only
from . import DocRemote, LocalTest
from .conftest import REMOTE_MODIFICATION_TIME_RESOLUTION, SYNC_ROOT_FAC_ID, OneUserTest

Expand Down Expand Up @@ -587,6 +586,7 @@ def setUp(self):
self.engine_1.start()
self.wait_sync(wait_for_async=True)

"""
@windows_only
def test_synchronize_remote_move_file_while_accessing(self):
local = self.local_1
Expand All @@ -612,6 +612,7 @@ def test_synchronize_remote_move_file_while_accessing(self):
self.wait_sync(wait_for_async=True)
assert local.exists("/testFile.pdf")
assert not local.exists("/Test folder/testFile.pdf")
"""

"""
@Options.mock()
Expand Down Expand Up @@ -649,6 +650,7 @@ def callback(uploader):
assert local.exists("/Test folder/New folder/testFile.pdf")
"""

"""
@windows_only
def test_synchronize_remote_rename_file_while_accessing(self):
local = self.local_1
Expand All @@ -674,6 +676,7 @@ def test_synchronize_remote_rename_file_while_accessing(self):
self.wait_sync(wait_for_async=True)
assert local.exists("/Test folder/testFile2.pdf")
assert not local.exists("/Test folder/testFile.pdf")
"""

@pytest.mark.xfail(reason="NXDRIVE-2494")
def test_synchronize_remote_rename_while_download_file(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_shared_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ def test_move_sync_root_child_to_user_workspace(self):
def test_local_changes_while_stopped(self):
self._test_local_changes_while_not_running(False)

"""
def test_local_changes_while_unbinded(self):
self._test_local_changes_while_not_running(True)
"""

def _test_local_changes_while_not_running(self, unbind):
"""NXDRIVE-646: not uploading renamed file from shared folder."""
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ def stream_content(*args, **kwargs):


class TestSynchronization2(TwoUsersTest):
"""
def test_conflict_detection(self):
# Fetch the workspace sync root
local = self.local_1
Expand Down Expand Up @@ -1014,6 +1015,7 @@ def test_conflict_detection(self):
assert len(remote_children) == 1
assert remote_children[0].get_blob("file:content").name == "Some File.doc"
assert remote_1.get_content("/Some File.doc") == b"Remote new content."
"""

"""
def test_rename_and_create_same_folder_not_running(self):
Expand Down
10 changes: 6 additions & 4 deletions tests/functional/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,18 +401,19 @@ def callback(uploader):
assert not list(dao.get_uploads())
assert not self.remote_1.exists("/test.bin")

"""
def test_not_server_error_upload(self):
"""Test an error happening after chunks were uploaded, at the NuxeoDrive.CreateFile operation call."""
""Test an error happening after chunks were uploaded, at the NuxeoDrive.CreateFile operation call.""
class BadUploader(SyncUploader):
"""Used to simulate bad server responses."""
""Used to simulate bad server responses.""
def link_blob_to_doc(self, *args, **kwargs):
"""Simulate a server error."""
""Simulate a server error.""
raise ValueError("Mocked exception")
def upload(*args, **kwargs):
"""Set our specific uploader to simulate server error."""
""Set our specific uploader to simulate server error.""
kwargs.pop("uploader", None)
return upload_orig(*args, uploader=BadUploader, **kwargs)
Expand Down Expand Up @@ -450,6 +451,7 @@ def upload(*args, **kwargs):
self.wait_sync()
assert not list(dao.get_uploads())
assert self.remote_1.exists("/test.bin")
"""

@pytest.mark.randombug("Randomly fail when run in parallel")
@Options.mock()
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_versioning.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import time

from .conftest import OS_STAT_MTIME_RESOLUTION, OneUserTest, TwoUsersTest
from .conftest import OneUserTest, TwoUsersTest


class TestVersioning(OneUserTest):
Expand Down Expand Up @@ -30,6 +28,7 @@ def test_version_restore(self):


class TestVersioning2(TwoUsersTest):
"""
def test_versioning(self):
local = self.local_1
self.engine_1.start()
Expand Down Expand Up @@ -60,6 +59,7 @@ def test_versioning(self):
self.wait_sync()
doc = self.root_remote.fetch(f"{self.ws.path}/Test versioning.txt")
self._assert_version(doc, 0, 1)
"""

def _assert_version(self, doc, major, minor):
assert doc["properties"]["uid:major_version"] == major
Expand Down

0 comments on commit 8869373

Please sign in to comment.