Squish: Fix handling of server issues in tst_codepasting

Change-Id: I35d8dbeb11be104a1af2956125a29c4606c7e050
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Loehning
2018-07-27 15:32:44 +02:00
parent 3f97874ca1
commit 7cc5376f0d

View File

@@ -43,6 +43,7 @@ def invalidPasteId(protocol):
return -1
def closeHTTPStatusAndPasterDialog(protocol, pasterDialog):
try:
mBoxStr = "{type='QMessageBox' unnamed='1' visible='1' windowTitle?='%s *'}" % protocol
mBox = waitForObject(mBoxStr, 1000)
text = str(mBox.text)
@@ -52,6 +53,10 @@ def closeHTTPStatusAndPasterDialog(protocol, pasterDialog):
if 'Service Unavailable' in text:
test.warning(text)
return True
except:
t,v = sys.exc_info()[:2]
test.warning("An exception occurred in closeHTTPStatusAndPasterDialog(): %s(%s)"
% (str(t), str(v)))
test.log("Closed dialog without expected error.", text)
return False
@@ -90,11 +95,9 @@ def pasteFile(sourceFile, protocol):
output = str(outputWindow.plainText).splitlines()[-1]
except:
output = ""
try:
if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'):
resetFiles()
raise Exception(serverProblems)
except:
pass
stdErrOut = aut.readStderr()
match = re.search("^%s protocol error: (.*)$" % protocol, stdErrOut, re.MULTILINE)
if match:
@@ -123,11 +126,8 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting):
try:
pasteModel = waitForObject(":PasteSelectDialog.listWidget_QListWidget").model()
except:
try:
if closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog'):
closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog')
return -1
except:
pass
waitFor("pasteModel.rowCount() > 1", 20000)
if (not skippedPasting and not protocol == NAME_PBCA
and not any(map(lambda str:pasteId in str, dumpItems(pasteModel)))):