diff options
author | swoichha <swoichhaa@gmail.com> | 2021-08-13 13:39:13 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-09-06 15:15:04 +0300 |
commit | b4f61d0ba844286a45bc93bd5cf797944f8941d9 (patch) | |
tree | afc2ed067af19c14d37a9610c3304ceb4364faf3 /test/gui/shared/scripts | |
parent | dc1982a34432e5611f7c9921a5326ee99500300c (diff) |
[tests-only]fix object name for adding users
Diffstat (limited to 'test/gui/shared/scripts')
-rw-r--r-- | test/gui/shared/scripts/bdd_hooks.py | 43 | ||||
-rw-r--r-- | test/gui/shared/scripts/helpers/SetupClientHelper.py | 9 | ||||
-rw-r--r-- | test/gui/shared/scripts/names.py | 1 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py | 28 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/PublicLinkDialog.py | 2 |
5 files changed, 68 insertions, 15 deletions
diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index 6191035b6..380847b53 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -30,8 +30,11 @@ def hook(context): 'localBackendUrl': os.environ.get( 'BACKEND_HOST', cfg.get('DEFAULT', 'BACKEND_HOST') ), - 'clientSyncPath': os.environ.get( - 'CLIENT_SYNC_PATH', cfg.get('DEFAULT', 'CLIENT_SYNC_PATH') + 'clientSyncPathUser1': os.environ.get( + 'CLIENT_SYNC_PATH_USER1', cfg.get('DEFAULT', 'CLIENT_SYNC_PATH_USER1') + ), + 'clientSyncPathUser2': os.environ.get( + 'CLIENT_SYNC_PATH_USER2', cfg.get('DEFAULT', 'CLIENT_SYNC_PATH_USER2') ), 'clientSyncTimeout': os.environ.get( 'CLIENT_SYNC_TIMEOUT', cfg.get('DEFAULT', 'CLIENT_SYNC_TIMEOUT') @@ -46,11 +49,17 @@ def hook(context): if context.userData['localBackendUrl'] == '': context.userData['localBackendUrl'] = 'https://localhost:9200' - if context.userData['clientSyncPath'] == '': - context.userData['clientSyncPath'] = '/tmp/client-bdd/' + if context.userData['clientSyncPathUser1'] == '': + context.userData['clientSyncPathUser1'] = '/tmp/client-bdd-user1/' + else: + context.userData['clientSyncPathUser1'] = ( + context.userData['clientSyncPathUser1'].rstrip("/") + "/" + ) # make sure there is always one trailing slash + if context.userData['clientSyncPathUser2'] == '': + context.userData['clientSyncPathUser2'] = '/tmp/client-bdd-user2/' else: - context.userData['clientSyncPath'] = ( - context.userData['clientSyncPath'].rstrip("/") + "/" + context.userData['clientSyncPathUser2'] = ( + context.userData['clientSyncPathUser2'].rstrip("/") + "/" ) # make sure there is always one trailing slash if context.userData['clientSyncTimeout'] == '': context.userData['clientSyncTimeout'] = 60 @@ -59,8 +68,11 @@ def hook(context): context.userData['clientSyncTimeout'] ) - if not os.path.exists(context.userData['clientSyncPath']): - os.makedirs(context.userData['clientSyncPath']) + if not os.path.exists(context.userData['clientSyncPathUser1']): + os.makedirs(context.userData['clientSyncPathUser1']) + + if not os.path.exists(context.userData['clientSyncPathUser2']): + os.makedirs(context.userData['clientSyncPathUser2']) if context.userData['middlewareUrl'] == '': context.userData['middlewareUrl'] = 'http://localhost:3000/' @@ -89,9 +101,20 @@ def hook(context): snooze(5) # ToDo wait smarter till the app died # delete local files/folders - for filename in os.listdir(context.userData['clientSyncPath']): + for filename in os.listdir(context.userData['clientSyncPathUser1']): + test.log("Deleting :" + filename) + file_path = os.path.join(context.userData['clientSyncPathUser1'], filename) + try: + if os.path.isfile(file_path) or os.path.islink(file_path): + os.unlink(file_path) + elif os.path.isdir(file_path): + shutil.rmtree(file_path) + except Exception as e: + print('Failed to delete %s. Reason: %s' % (file_path, e)) + + for filename in os.listdir(context.userData['clientSyncPathUser2']): test.log("Deleting :" + filename) - file_path = os.path.join(context.userData['clientSyncPath'], filename) + file_path = os.path.join(context.userData['clientSyncPathUser2'], filename) try: if os.path.isfile(file_path) or os.path.islink(file_path): os.unlink(file_path) diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py index f882930d0..c054b4d26 100644 --- a/test/gui/shared/scripts/helpers/SetupClientHelper.py +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -8,7 +8,12 @@ confFilePath = confdir + 'owncloud.cfg' def substituteInLineCodes(context, value): value = value.replace('%local_server%', context.userData['localBackendUrl']) - value = value.replace('%client_sync_path%', context.userData['clientSyncPath']) + value = value.replace( + '%client_sync_path_user1%', context.userData['clientSyncPathUser1'] + ) + value = value.replace( + '%client_sync_path_user2%', context.userData['clientSyncPathUser2'] + ) value = value.replace( '%local_server_hostname%', urlparse(context.userData['localBackendUrl']).netloc ) @@ -78,7 +83,7 @@ def setUpClient(context, username, displayName, confFilePath): 'displayUserName': displayName, 'davUserName': userFirstName[0].lower(), 'displayUserFirstName': userFirstName[0], - 'client_sync_path': context.userData['clientSyncPath'], + 'client_sync_path': context.userData['clientSyncPathUser1'], 'local_server': context.userData['localBackendUrl'], } userSetting = userSetting.format(**args) diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 783b35dbe..966a89a56 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -102,3 +102,4 @@ sharingDialog_Close_QPushButton = {"text": "Close", "type": "QPushButton", "unna stack_Enable_experimental_placeholder_mode_QPushButton = {"container": settings_stack_QStackedWidget, "text": "Enable experimental placeholder mode", "type": "QPushButton", "unnamed": 1, "visible": 1} disable_virtual_file_support_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Disable virtual file support?"} disable_virtual_file_support_Disable_support_QPushButton = {"text": "Disable support", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": disable_virtual_file_support_QMessageBox} +error_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Error"}
\ No newline at end of file diff --git a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py index bba29edb3..2d56c124b 100644 --- a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py +++ b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py @@ -1,6 +1,7 @@ import names import squish from helpers.SetupClientHelper import getClientDetails +import test class AccountConnectionWizard: @@ -11,11 +12,26 @@ class AccountConnectionWizard: SELECT_LOCAL_FOLDER = names.pbSelectLocalFolder_QPushButton DIRECTORY_NAME_BOX = names.fileNameEdit_QLineEdit CHOOSE_BUTTON = names.qFileDialog_Choose_QPushButton - CONNECT_BUTTON = names.owncloudWizard_qt_passive_wizardbutton1_QPushButton + FINISH_BUTTON = { + "name": "qt_wizard_finish", + "type": "QPushButton", + "visible": 1, + "window": names.owncloudWizard_OCC_OwncloudWizard, + } + ERROR_OK_BUTTON = { + "text": "OK", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + "window": names.error_QMessageBox, + } def __init__(self): pass + def sanitizeFolderPath(self, folderPath): + return folderPath.rstrip("/") + def addAccount(self, context): server, user, password, localfolder = getClientDetails(context) @@ -27,8 +43,16 @@ class AccountConnectionWizard: squish.type(squish.waitForObject(self.USERNAME_BOX), "<Tab>") squish.type(squish.waitForObject(self.PASSWORD_BOX), password) squish.clickButton(squish.waitForObject(self.NEXT_BUTTON)) + try: + squish.clickButton(squish.waitForObject(self.ERROR_OK_BUTTON)) + except LookupError: + pass squish.clickButton(squish.waitForObject(self.SELECT_LOCAL_FOLDER)) squish.mouseClick(squish.waitForObject(self.DIRECTORY_NAME_BOX)) squish.type(squish.waitForObject(self.DIRECTORY_NAME_BOX), localfolder) squish.clickButton(squish.waitForObject(self.CHOOSE_BUTTON)) - squish.clickButton(squish.waitForObject(self.CONNECT_BUTTON)) + test.compare( + str(squish.waitForObjectExists(self.SELECT_LOCAL_FOLDER).text), + self.sanitizeFolderPath(localfolder), + ) + squish.clickButton(squish.waitForObject(self.FINISH_BUTTON)) diff --git a/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py index 536bb002d..f89baa171 100644 --- a/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py +++ b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py @@ -76,7 +76,7 @@ class PublicLinkDialog: test.compare( str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), - resource.replace(context.userData['clientSyncPath'], ''), + resource.replace(context.userData['clientSyncPathUser1'], ''), ) if radioObjectName: |