-
Notifications
You must be signed in to change notification settings - Fork 671
/
Copy pathsync_context.py
295 lines (205 loc) · 8.35 KB
/
sync_context.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
from pageObjects.SyncConnectionWizard import SyncConnectionWizard
from pageObjects.SyncConnection import SyncConnection
from pageObjects.Toolbar import Toolbar
from pageObjects.Activity import Activity
from pageObjects.Settings import Settings
from helpers.ConfigHelper import get_config, isWindows, set_config
from helpers.SyncHelper import (
waitForFileOrFolderToSync,
waitForFileOrFolderToHaveSyncError,
)
from helpers.SetupClientHelper import getTempResourcePath, setCurrentUserSyncPath
@Given('the user has paused the file sync')
def step(context):
SyncConnection.pauseSync()
@When('the user resumes the file sync on the client')
def step(context):
SyncConnection.resumeSync()
@When('the user force syncs the files')
def step(context):
SyncConnection.forceSync()
@When('the user waits for the files to sync')
def step(context):
waitForFileOrFolderToSync(getResourcePath('/'))
@When(r'the user waits for (file|folder) "([^"]*)" to be synced', regexp=True)
def step(context, type, resource):
resource = getResourcePath(resource)
waitForFileOrFolderToSync(resource, type)
@When(r'the user waits for (file|folder) "([^"]*)" to have sync error', regexp=True)
def step(context, type, resource):
resource = getResourcePath(resource)
waitForFileOrFolderToHaveSyncError(resource, type)
@When(
r'user "([^"]*)" waits for (file|folder) "([^"]*)" to have sync error', regexp=True
)
def step(context, username, type, resource):
resource = getResourcePath(resource, username)
waitForFileOrFolderToHaveSyncError(resource, type)
@When("the user enables virtual file support")
def step(context):
SyncConnection.enableVFS()
# TODO: remove snooze with proper wait
# let the client re-sync
snooze(get_config("minSyncTimeout"))
@Then('the "|any|" button should be available')
def step(context, item):
SyncConnection.openMenu()
SyncConnection.hasMenuItem(item)
@Then('the "|any|" button should not be available')
def step(context, item):
SyncConnection.openMenu()
test.compare(
SyncConnection.menu_item_exists(item),
False,
f'Menu item "{item}" does not exist.',
)
@When("the user disables virtual file support")
def step(context):
SyncConnection.disableVFS()
# TODO: remove snooze with proper wait
# let the client re-sync
snooze(get_config("minSyncTimeout"))
@When('the user clicks on the activity tab')
def step(context):
Toolbar.openActivity()
@Then('the table of conflict warnings should include file "|any|"')
def step(context, filename):
Activity.checkFileExist(filename)
@Then('the file "|any|" should be blacklisted')
def step(context, filename):
test.compare(True, Activity.resourceIsBlacklisted(filename), "File is Blacklisted")
@Then('the file "|any|" should be ignored')
def step(context, filename):
test.compare(True, Activity.resourceIsIgnored(filename), "File is Ignored")
@When('the user selects "|any|" tab in the activity')
def step(context, tabName):
Activity.clickTab(tabName)
@Then("the toolbar should have the following tabs:")
def step(context):
for tabName in context.table:
Toolbar.hasItem(tabName[0])
@When('the user selects the following folders to sync:')
def step(context):
folders = []
for row in context.table[1:]:
folders.append(row[0])
SyncConnectionWizard.selectFoldersToSync(folders)
SyncConnectionWizard.addSyncConnection()
@When('the user sorts the folder list by "|any|"')
def step(context, headerText):
headerText = headerText.capitalize()
if headerText in ["Size", "Name"]:
SyncConnectionWizard.sortBy(headerText)
else:
raise Exception("Sorting by '" + headerText + "' is not supported.")
@Then('the sync all checkbox should be checked')
def step(context):
test.compare(
SyncConnectionWizard.isRootFolderChecked(), True, "Sync all checkbox is checked"
)
@Then("the folders should be in the following order:")
def step(context):
rowIndex = 0
for row in context.table[1:]:
expectedFolder = row[0]
actualFolder = SyncConnectionWizard.getItemNameFromRow(rowIndex)
test.compare(actualFolder, expectedFolder)
rowIndex += 1
@When('the user selects "|any|" space in sync connection wizard')
def step(context, space_name):
if get_config("ocis"):
SyncConnectionWizard.selectSpaceToSync(space_name)
SyncConnectionWizard.nextStep()
set_config('syncConnectionName', space_name)
@When('the user sets the sync path in sync connection wizard')
def step(context):
SyncConnectionWizard.setSyncPathInSyncConnectionWizard()
@When(
'the user sets the temp folder "|any|" as local sync path in sync connection wizard'
)
def step(context, folderName):
sync_path = getTempResourcePath(folderName)
SyncConnectionWizard.setSyncPathInSyncConnectionWizard(sync_path)
if get_config("ocis"):
# empty connection name when using temporary locations
set_config('syncConnectionName', '')
setCurrentUserSyncPath(sync_path)
@When('the user selects "|any|" as a remote destination folder')
def step(context, folderName):
# There's no remote destination section with oCIS server
if not get_config("ocis"):
SyncConnectionWizard.selectRemoteDestinationFolder(folderName)
@When('the user syncs the "|any|" space')
def step(context, spaceName):
SyncConnectionWizard.syncSpace(spaceName)
@Then('the settings tab should have the following options in the general section:')
def step(context):
for item in context.table:
Settings.check_general_option(item[0])
@Then('the settings tab should have the following options in the advanced section:')
def step(context):
for item in context.table:
Settings.check_advanced_option(item[0])
@Then('the settings tab should have the following options in the network section:')
def step(context):
for item in context.table:
Settings.check_network_option(item[0])
@When('the user opens the about dialog')
def step(context):
Settings.open_about_button()
@Then('the about dialog should be opened')
def step(context):
Settings.wait_for_about_dialog_to_be_visible()
@When('the user adds the folder sync connection')
def step(context):
SyncConnectionWizard.addSyncConnection()
@When("user unselects all the remote folders")
def step(context):
SyncConnectionWizard.deselectAllRemoteFolders()
@When("the user |word| VFS support for Windows")
def step(context, action):
if isWindows():
action = action.rstrip("s")
SyncConnectionWizard.enableOrDisableVfsSupport(action)
@When('user unselects a folder "|any|" in selective sync')
def step(context, folder_name):
SyncConnection.choose_what_to_sync()
SyncConnection.unselect_folder_in_selective_sync(folder_name)
@Then("the sync folder list should be empty")
def step(context):
test.compare(
0,
SyncConnection.get_folder_connection_count(),
"Sync connections should be empty",
)
@When('the user navigates back in the sync connection wizard')
def step(context):
SyncConnectionWizard.back()
@When('the user creates a folder "|any|" in the remote destination wizard')
def step(context, folder_name):
if not get_config("ocis"):
SyncConnectionWizard.create_folder_in_remote_destination(folder_name)
@When('the user refreshes the remote destination in the sync connection wizard')
def step(context):
if not get_config("ocis"):
SyncConnectionWizard.refresh_remote()
@Then('the folder "|any|" should be present in the remote destination wizard')
def step(context, folder_name):
if not get_config("ocis"):
has_folder, folder_selector = SyncConnectionWizard.has_remote_folder(
folder_name
)
test.compare(True, has_folder, "Folder should be in the remote list")
@When('the user selects remove folder sync connection option')
def step(context):
SyncConnection.remove_folder_sync_connection()
@When('the user cancels the folder sync connection removal dialog')
def step(context):
SyncConnection.cancel_folder_sync_connection_removal()
@When('the user removes the folder sync connection')
def step(context):
SyncConnection.remove_folder_sync_connection()
SyncConnection.confirm_folder_sync_connection_removal()
@Then('the file "|any|" should have status "|any|" in the activity tab')
def step(context, file_name, status):
Activity.hasSyncStatus(file_name, status)