Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 39 additions & 14 deletions test/gui/shared/steps/file_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from helpers.SetupClientHelper import get_resource_path, get_temp_resource_path
from helpers.SyncHelper import wait_for_client_to_be_ready, listen_sync_status_for_item
from helpers.ConfigHelper import get_config
from helpers.ConfigHelper import get_config, is_windows
from helpers.FilesHelper import (
build_conflicted_regex,
sanitize_path,
Expand Down Expand Up @@ -97,26 +97,27 @@ def extract_zip(zip_file_path, destination_dir):


def add_copy_suffix(resource_path, resource_type):
suffix = ' (Copy)'
if resource_type == 'file':
source_dir = resource_path.rsplit('.', 1)
return source_dir[0] + ' - Copy.' + source_dir[-1]
return resource_path + ' - Copy'
return source_dir[0] + suffix + '.' + source_dir[-1]
return resource_path + suffix


def copy_resource(resource_type, source, destination, from_files_for_upload=False):
if from_files_for_upload:
source_dir = get_file_for_upload(source)
source = get_file_for_upload(source)
else:
source_dir = get_resource_path(source)
destination_dir = get_resource_path(destination)
if source_dir == destination_dir and destination_dir != '/':
destination_dir = add_copy_suffix(source, resource_type)
source = get_resource_path(source)
destination = get_resource_path(destination)
if source == destination and destination != '/':
destination = add_copy_suffix(source, resource_type)

wait_for_client_to_be_ready()
listen_sync_status_for_item(destination_dir, resource_type)
listen_sync_status_for_item(destination, resource_type)
if resource_type == 'folder':
return shutil.copytree(source_dir, destination_dir)
return shutil.copy2(source_dir, destination_dir)
return shutil.copytree(source, destination)
return shutil.copy2(source, destination)


def move_resource(username, resource_type, source, destination, is_temp_folder=False):
Expand Down Expand Up @@ -164,9 +165,14 @@ def step(context, _, filename, filesize):
create_file_with_size(filename, filesize)


@When(r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"', regexp=True)
def step(context, resource_type, file_name, destination):
copy_resource(resource_type, file_name, destination, False)
@When(r'the user copies (file|folder) "([^"]*)" into folder "([^"]*)"', regexp=True)
def step(context, resource_type, resource_name, destination_dir):
copy_resource(resource_type, resource_name, destination_dir, False)


@When(r'the user copies (file|folder) "([^"]*)" into the same folder', regexp=True)
def step(context, resource_type, resource_name):
copy_resource(resource_type, resource_name, resource_name, False)


@When(r'the user renames a (?:file|folder) "([^"]*)" to "([^"]*)"', regexp=True)
Expand Down Expand Up @@ -298,6 +304,16 @@ def step(context, file_number, file_size, folder_name):
)


@When(
r'user "([^"]*)" reads the content of file "([^"]*)"',
regexp=True,
)
def step(context, username, file):
file_path = get_resource_path(file, username)
with open(file_path, 'r') as f:
f.read()


@When(
r'user "([^"]*)" moves (folder|file) "([^"]*)" from the temp folder into the sync folder',
regexp=True,
Expand All @@ -307,6 +323,15 @@ def step(context, username, resource_type, resource_name):
move_resource(username, resource_type, source_dir, '/', True)


@When(
r'user "([^"]*)" moves (folder|file) "([^"]*)" to the temp folder',
regexp=True,
)
def step(context, username, resource_type, resource_name):
destination= join(get_config('tempFolderPath'), resource_name)
move_resource(username, resource_type, resource_name, destination)


@When(
r'user "([^"]*)" moves (file|folder) "([^"]*)" to "([^"]*)" in the sync folder',
regexp=True,
Expand Down
2 changes: 1 addition & 1 deletion test/gui/shared/steps/vfs_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from helpers.SetupClientHelper import get_resource_path


@Then('the placeholder of file "|any|" should exist on the file system')
@Then('the placeholder file "|any|" should exist on the file system')
def step(context, file_name):
resource_path = get_resource_path(file_name)
size_on_disk = get_file_size_on_disk(resource_path)
Expand Down
8 changes: 4 additions & 4 deletions test/gui/tst_syncing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ Feature: Syncing files
"""
test content
"""
And the user copies the folder "original" to "copied"
And the user waits for folder "copied" to be synced
And the user copies folder "original" into the same folder
And the user waits for folder "original (Copy)" to be synced
Then as "Alice" folder "original" should exist in the server
And as "Alice" the file "original/localFile.txt" should have the content "test content" in the server
And as "Alice" folder "copied" should exist in the server
And as "Alice" the file "copied/localFile.txt" should have the content "test content" in the server
And as "Alice" folder "original (Copy)" should exist in the server
And as "Alice" the file "original (Copy)/localFile.txt" should have the content "test content" in the server

@issue-9281
Scenario: Verify that you can create a subfolder with long name(~220 characters)
Expand Down
39 changes: 26 additions & 13 deletions test/gui/tst_vfs/test.feature
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
@skipOnLinux
Feature: Enable/disable virtual file support
Feature: VFS support
As a user
I want to enable virtual file support
So that I can synchronize virtual files with local folder
I want to sync files with vfs
So that I can decide which files to download


Scenario: Copy and paste virtual file
Scenario: Default VFS sync
Given user "Alice" has been created in the server with default attributes
And user "Alice" has uploaded file with content "openCloud" to "testFile.txt" in the server
And user "Alice" has created folder "parent" in the server
And user "Alice" has uploaded file with content "some contents" to "parent/lorem.txt" in the server
And user "Alice" has set up a client with default settings
Then the placeholder file "testFile.txt" should exist on the file system
And the placeholder file "parent/lorem.txt" should exist on the file system
When user "Alice" reads the content of file "parent/lorem.txt"
Then the file "parent/lorem.txt" should be downloaded
And the placeholder file "testFile.txt" should exist on the file system


Scenario: Copy placeholder file
Given user "Alice" has been created in the server with default attributes
And user "Alice" has uploaded file with content "sample file" to "sampleFile.txt" in the server
And user "Alice" has uploaded file with content "lorem file" to "lorem.txt" in the server
And user "Alice" has uploaded file with content "test file" to "testFile.txt" in the server
And user "Alice" has created folder "Folder" in the server
And user "Alice" has set up a client with default settings
Then the placeholder of file "lorem.txt" should exist on the file system
And the placeholder of file "sampleFile.txt" should exist on the file system
And the placeholder of file "testFile.txt" should exist on the file system
Then the placeholder file "lorem.txt" should exist on the file system
And the placeholder file "sampleFile.txt" should exist on the file system
And the placeholder file "testFile.txt" should exist on the file system
When user "Alice" copies file "sampleFile.txt" to temp folder
And the user copies the file "lorem.txt" to "Folder"
And the user copies the file "testFile.txt" to "testFile.txt"
And the user copies file "lorem.txt" into folder "Folder"
And the user copies file "testFile.txt" into the same folder
And the user waits for file "Folder/lorem.txt" to be synced
Then the file "sampleFile.txt" should be downloaded
And the file "Folder/lorem.txt" should be downloaded
And the file "lorem.txt" should be downloaded
And the file "testFile.txt" should be downloaded
And the file "testFile - Copy.txt" should be downloaded
And the file "testFile (Copy).txt" should be downloaded
And as "Alice" file "Folder/lorem.txt" should exist in the server
And as "Alice" file "lorem.txt" should exist in the server
And as "Alice" file "sampleFile.txt" should exist in the server
And as "Alice" file "testFile.txt" should exist in the server
And as "Alice" file "testFile - Copy.txt" should exist in the server
And as "Alice" file "testFile (Copy).txt" should exist in the server


Scenario: Move virtual file
Scenario: Move placeholder file
Given user "Alice" has been created in the server with default attributes
And user "Alice" has uploaded file with content "lorem file" to "lorem.txt" in the server
And user "Alice" has uploaded file with content "some contents" to "sampleFile.txt" in the server
Expand All @@ -40,7 +53,7 @@ Feature: Enable/disable virtual file support
When user "Alice" moves file "lorem.txt" to "Folder" in the sync folder
And user "Alice" moves file "sampleFile.txt" to the temp folder
And the user waits for file "Folder/lorem.txt" to be synced
Then the placeholder of file "Folder/lorem.txt" should exist on the file system
Then the placeholder file "Folder/lorem.txt" should exist on the file system
And as "Alice" file "Folder/lorem.txt" should exist in the server
And as "Alice" file "lorem.txt" should not exist in the server
And as "Alice" file "sampleFile.txt" should not exist in the server