def test_runEarthQuakeGuidelinesFunction(self): """GUI runs with Shakemap 2009 and Padang Buildings""" # Push OK with the left mouse button myButton = DOCK.pbnRunStop setCanvasCrs(GEOCRS, True) setPadangGeoExtent() myMessage = 'Run button was not enabled' assert myButton.isEnabled(), myMessage #QTest.keyClick(DOCK.cboHazard, QtCore.Qt.Key_Down) #QTest.keyClick(DOCK.cboHazard, QtCore.Qt.Key_Enter) # #QTest.keyClick(DOCK.cboExposure, QtCore.Qt.Key_Down) #QTest.keyClick(DOCK.cboExposure, QtCore.Qt.Key_Enter) # Hazard layer myIndex = DOCK.cboHazard.findText(PADANG2009_title) assert myIndex != -1, 'Padang 2009 scenario hazard layer not found' DOCK.cboHazard.setCurrentIndex(myIndex) # Exposure layer myIndex = DOCK.cboExposure.findText('Padang_WGS84') myMessage = ('Could not find layer Padang_WGS84:\n' '%s' % (combosToString(DOCK))) assert myIndex != -1, myMessage DOCK.cboExposure.setCurrentIndex(myIndex) # Impact function myIndex = DOCK.cboFunction.findText('Earthquake Guidelines Function') msg = ('Earthquake Guidelines function not ' 'found: ' + combosToString(DOCK)) assert myIndex != -1, msg DOCK.cboFunction.setCurrentIndex(myIndex) myDict = getUiState(DOCK) myExpectedDict = {'Hazard': PADANG2009_title, 'Exposure': 'Padang_WGS84', 'Impact Function': 'Earthquake Guidelines Function', 'Run Button Enabled': True} myMessage = 'Got:\n %s\nExpected:\n%s\n%s' % ( myDict, myExpectedDict, combosToString(DOCK)) assert myDict == myExpectedDict, myMessage QTest.mouseClick(myButton, QtCore.Qt.LeftButton) myResult = DOCK.wvResults.page().currentFrame().toPlainText() # Expected output: #Buildings Total #All: 3160 #Low damage (10-25%): 0 #Medium damage (25-50%): 0 #Pre merge of clip on steroids branch: #High damage (50-100%): 3160 # Post merge of clip on steoids branch: #High damage (50-100%): 2993 myMessage = ('Unexpected result returned for Earthquake guidelines' 'function. Expected:\n "All" count of 2993, ' 'received: \n %s' % myResult) assert '2993' in myResult, myMessage
def test_runEarthquakeFatalityFunction_small(self): """Padang 2009 fatalities estimated correctly (small extent)""" # Push OK with the left mouse button myButton = DOCK.pbnRunStop setCanvasCrs(GEOCRS, True) setPadangGeoExtent() myMessage = 'Run button was not enabled' assert myButton.isEnabled(), myMessage # Simulate choosing another combo item and running # the model again myIndex = DOCK.cboHazard.findText(PADANG2009_title) assert myIndex != -1, 'Padang 2009 scenario hazard layer not found' DOCK.cboHazard.setCurrentIndex(myIndex) # Exposure layers myIndex = DOCK.cboExposure.findText('People') assert myIndex != -1, 'People' DOCK.cboExposure.setCurrentIndex(myIndex) # Choose impact function myIndex = DOCK.cboFunction.findText('Earthquake Fatality Function') msg = ('Earthquake Fatality Function not ' 'found: ' + combosToString(DOCK)) assert myIndex != -1, msg DOCK.cboFunction.setCurrentIndex(myIndex) myDict = getUiState(DOCK) myExpectedDict = {'Hazard': PADANG2009_title, 'Exposure': 'People', 'Impact Function': 'Earthquake Fatality Function', 'Run Button Enabled': True} myMessage = 'Got unexpected state: %s\nExpected: %s\n%s' % ( myDict, myExpectedDict, combosToString(DOCK)) assert myDict == myExpectedDict, myMessage QTest.mouseClick(myButton, QtCore.Qt.LeftButton) myResult = DOCK.wvResults.page().currentFrame().toPlainText() # Check against expected output myMessage = ('Unexpected result returned for Earthquake Fatality ' 'Function Expected: fatality count of ' '116 , received: \n %s' % myResult) assert '116' in myResult, myMessage myMessage = ('Unexpected result returned for Earthquake Fatality ' 'Function Expected: total population count of ' '847529 , received: \n %s' % myResult) assert '847529' in myResult, myMessage