Skip to content

Commit

Permalink
open only one socket connection per test scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Aug 2, 2022
1 parent b28b46e commit f5e80b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def hook(context):

@OnScenarioEnd
def hook(context):
# close socket connection
global socketConnect
if socketConnect:
socketConnect.connected = False
socketConnect._sock.close()

# Currently, this workaround is needed because we cannot find out a way to determine the pass/fail status of currently running test scenario.
# And, resultCount("errors") and resultCount("fails") return the total number of error/failed test scenarios of a test suite.
global previousFailResultCount
Expand Down
15 changes: 11 additions & 4 deletions test/gui/shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/
# if the IDE fails to reference the script, add the folder in Edit->Preferences->PyDev->Interpreters->Libraries
sys.path.append(os.path.realpath('../../../shell_integration/nautilus/'))
import syncstate
from syncstate import SocketConnect
import functools


Expand Down Expand Up @@ -142,11 +142,18 @@ def step(context):
newAccount.addAccountCredential(context)


def getSocketConnection():
global socketConnect
if not socketConnect or not socketConnect.connected:
socketConnect = SocketConnect()
return socketConnect


# Using socket API to check file sync status
def hasSyncStatus(type, itemName, status):
if type != 'FILE' and type != 'FOLDER':
raise Exception("type must be 'FILE' or 'FOLDER'")
socketConnect = syncstate.SocketConnect()
socketConnect = getSocketConnection()
socketConnect.sendCommand("RETRIEVE_" + type + "_STATUS:" + itemName + "\n")

if not socketConnect.read_socket_data_with_timeout(0.1):
Expand Down Expand Up @@ -282,7 +289,7 @@ def sanitizePath(path):


def shareResource(resource):
socketConnect = syncstate.SocketConnect()
socketConnect = getSocketConnection()
socketConnect.sendCommand("SHARE:" + resource + "\n")
if not socketConnect.read_socket_data_with_timeout(0.1):
return False
Expand Down Expand Up @@ -376,7 +383,7 @@ def collaboratorShouldBeListed(
context, receiver, resource, permissions, receiverCount=0
):
resource = getResourcePath(context, resource)
socketConnect = syncstate.SocketConnect()
socketConnect = getSocketConnection()
socketConnect.sendCommand("SHARE:" + resource + "\n")
permissionsList = permissions.split(',')

Expand Down

0 comments on commit f5e80b6

Please sign in to comment.