Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui-test][full-ci] enable invalid-name check #11892

Merged
merged 5 commits into from
Oct 3, 2024
Merged
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
4 changes: 2 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ def lint_gui_test():
def python_lint():
return [{
"name": "python-lint",
"image": OC_CI_ALPINE,
"image": OC_CI_SQUISH,
"commands": [
"apk add --no-cache py3-pylint black",
"make -C %s pip-install" % dir["guiTest"],
"make -C %s python-lint" % dir["guiTest"],
],
}]
Expand Down
5 changes: 3 additions & 2 deletions test/gui/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ disable=
too-many-public-methods,
bare-except,
fixme,
; TODO: enable later
invalid-name,
fail-under=10
ignore-paths=^tst_.*/test.py$,
shared/scripts/names.py,
Expand All @@ -39,10 +37,13 @@ unsafe-load-any-extension=no

[BASIC]
attr-naming-style=snake_case
; TODO: enable it later
; class-attribute-naming-style=snake_case
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
class-const-naming-style=UPPER_CASE
class-naming-style=PascalCase
const-naming-style=UPPER_CASE
function-naming-style=snake_case
inlinevar-naming-style=snake_case
method-naming-style=snake_case
module-naming-style=any
variable-naming-style=snake_case
Expand Down
4 changes: 2 additions & 2 deletions test/gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ pip-install:
.PHONY: python-lint
python-lint:
black --check --diff .
pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)
python3.10 -m pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)

.PHONY: python-lint-fix
python-lint-fix:
black .
pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)
python3.10 -m pylint --rcfile ./.pylintrc $(PYTHON_LINT_PATHS)

.PHONY: gherkin-lint
gherkin-lint:
Expand Down
26 changes: 13 additions & 13 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from urllib import request, error
from datetime import datetime

from helpers.StacktraceHelper import getCoredumps, generateStacktrace
from helpers.SyncHelper import closeSocketConnection, clearWaitedAfterSync
from helpers.StacktraceHelper import get_core_dumps, generate_stacktrace
from helpers.SyncHelper import close_socket_connection, clear_waited_after_sync
from helpers.SpaceHelper import delete_project_spaces
from helpers.api.provisioning import delete_created_groups, delete_created_users
from helpers.SetupClientHelper import wait_until_app_killed, unlock_keyring
Expand All @@ -31,8 +31,8 @@
get_config,
set_config,
clear_scenario_config,
isWindows,
isLinux,
is_windows,
is_linux,
)
from helpers.api.utils import url_join
from helpers.FilesHelper import prefix_path_namespace, cleanup_created_paths
Expand Down Expand Up @@ -74,7 +74,7 @@ def hook(context):
# set owncloud config file path
config_dir = get_config("clientConfigDir")
if os.path.exists(config_dir):
if len(os.listdir(config_dir)) and isWindows():
if len(os.listdir(config_dir)) and is_windows():
raise FileExistsError(
"Looks like you have previous client config in '"
+ config_dir
Expand Down Expand Up @@ -186,11 +186,11 @@ def save_screenrecord(filename):
# Order: 1
@OnScenarioEnd
def hook(context):
clearWaitedAfterSync()
closeSocketConnection()
clear_waited_after_sync()
close_socket_connection()

# capture a screenshot if there is error or test failure in the current scenario execution
if scenario_failed() and os.getenv("CI") and isLinux():
if scenario_failed() and os.getenv("CI") and is_linux():
# scenario name can have "/" which is invalid filename
filename = get_screenshot_name(context.title)
directory = os.path.join(get_config("guiTestReportDir"), "screenshots")
Expand All @@ -211,9 +211,9 @@ def hook(context):

# search coredumps after every test scenario
# CI pipeline might fail although all tests are passing
if coredumps := getCoredumps():
if coredumps := get_core_dumps():
try:
generateStacktrace(context.title, coredumps)
generate_stacktrace(context.title, coredumps)
test.log("Stacktrace generated!")
except OSError as err:
test.log("Exception occured:" + str(err))
Expand Down Expand Up @@ -253,16 +253,16 @@ def hook(context):
def teardown_client():
# Cleanup user accounts from UI for Windows platform
# It is not needed for Linux so skipping it in order to save CI time
if isWindows():
if is_windows():
# remove account from UI
# In Windows, removing only config and sync folders won't help
# so to work around that, remove the account connection
close_dialogs()
close_widgets()
accounts, _ = Toolbar.get_accounts()
for account in accounts:
Toolbar.openAccount(account["displayname"])
AccountSetting.removeAccountConnection()
Toolbar.open_account(account["displayname"])
AccountSetting.remove_account_connection()
if accounts:
squish.waitForObject(AccountConnectionWizard.SERVER_ADDRESS_BOX)

Expand Down
30 changes: 15 additions & 15 deletions test/gui/shared/scripts/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@ def get_config_from_env_file(env):
raise KeyError(f'Environment "{env}" not found in envs.txt')


def isWindows():
def is_windows():
return platform.system() == 'Windows'


def isLinux():
def is_linux():
return platform.system() == 'Linux'


def getWinUserHome():
def get_win_user_home():
return os.environ.get('UserProfile')


def getClientRootPath():
if isWindows():
return os.path.join(getWinUserHome(), 'owncloudtest')
def get_client_root_path():
if is_windows():
return os.path.join(get_win_user_home(), 'owncloudtest')
return os.path.join(gettempdir(), 'owncloudtest')


def getConfigHome():
if isWindows():
def get_config_home():
if is_windows():
# There is no way to set custom config path in windows
# TODO: set to different path if option is available
return os.path.join(getWinUserHome(), 'AppData', 'Roaming', 'ownCloud')
return os.path.join(get_win_user_home(), 'AppData', 'Roaming', 'ownCloud')
return os.path.join(get_config_from_env_file('XDG_CONFIG_HOME'), 'ownCloud')


def get_default_home_dir():
if isWindows():
return getWinUserHome()
if is_windows():
return get_win_user_home()
return os.environ.get('HOME')


Expand Down Expand Up @@ -90,9 +90,9 @@ def get_default_home_dir():
'lowestSyncTimeout': 1,
'middlewareUrl': 'http://localhost:3000/',
'clientLogFile': '-',
'clientRootSyncPath': getClientRootPath(),
'tempFolderPath': os.path.join(getClientRootPath(), 'temp'),
'clientConfigDir': getConfigHome(),
'clientRootSyncPath': get_client_root_path(),
'tempFolderPath': os.path.join(get_client_root_path(), 'temp'),
'clientConfigDir': get_config_home(),
'guiTestReportDir': os.path.abspath('../reports'),
'ocis': False,
'screenRecordOnFailure': False,
Expand Down Expand Up @@ -147,7 +147,7 @@ def init_config():
'guiTestReportDir',
):
# make sure there is always one trailing slash
if isWindows():
if is_windows():
value = value.replace('/', '\\')
CONFIG[key] = value.rstrip('\\') + '\\'
else:
Expand Down
10 changes: 5 additions & 5 deletions test/gui/shared/scripts/helpers/FilesHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import ctypes
import shutil

from helpers.ConfigHelper import isWindows
from helpers.ConfigHelper import is_windows


def buildConflictedRegex(filename):
def build_conflicted_regex(filename):
if "." in filename:
# TODO: improve this for complex filenames
namepart = filename.split(".")[0]
Expand All @@ -20,12 +20,12 @@ def buildConflictedRegex(filename):
return "%s \(conflicted copy \d{4}-\d{2}-\d{2} \d{6}\)" % filename


def sanitizePath(path):
def sanitize_path(path):
return path.replace("//", "/")


def prefix_path_namespace(path):
if isWindows():
if is_windows():
# https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#win32-file-namespaces
# disable string parsing
# - long path
Expand Down Expand Up @@ -94,7 +94,7 @@ def get_size_in_bytes(size):

def get_file_size_on_disk(resource_path):
file_size_high = ctypes.c_ulonglong(0)
if isWindows():
if is_windows():
return ctypes.windll.kernel32.GetCompressedFileSizeW(
ctypes.c_wchar_p(resource_path), ctypes.pointer(file_size_high)
)
Expand Down
Loading