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 Sep 7, 2022
1 parent 74aa37a commit 434a34a
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 @@ -151,6 +151,12 @@ def scenarioFailed():

@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 @@ -138,11 +138,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 @@ -278,7 +285,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 @@ -372,7 +379,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 434a34a

Please sign in to comment.