本文整理汇总了Python中safe_qgis.utilities.utilities_for_testing.setup_scenario函数的典型用法代码示例。如果您正苦于以下问题:Python setup_scenario函数的具体用法?Python setup_scenario怎么用?Python setup_scenario使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_scenario函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_cboAggregationToggle
def test_cboAggregationToggle(self):
"""Aggregation Combobox toggles on and off as expected."""
# With aggregation layer
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart',
aggregation_enabled_flag=True)
myMessage += ' when an aggregation layer is defined.'
assert myResult, myMessage
# With no aggregation layer
myLayer = DOCK.get_aggregation_layer()
myId = myLayer.id()
QgsMapLayerRegistry.instance().removeMapLayer(myId)
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_enabled_flag=False)
myMessage += ' when no aggregation layer is defined.'
assert myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:28,代码来源:test_dock.py
示例2: test_hasParametersButtonEnabled
def test_hasParametersButtonEnabled(self):
"""Function configuration button is enabled when layers are compatible.
"""
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='Penduduk Jakarta',
function='Need evacuation',
function_id='Flood Evacuation Function')
myToolButton = DOCK.toolFunctionOptions
myFlag = myToolButton.isEnabled()
assert myFlag, 'Expected configuration options button to be enabled'
开发者ID:feyeandal,项目名称:inasafe,代码行数:14,代码来源:test_dock.py
示例3: Xtest_extentsChanged
def Xtest_extentsChanged(self):
"""Memory requirements are calculated correctly when extents change.
"""
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='Penduduk Jakarta',
function='Need evacuation',
function_id='Flood Evacuation Function')
myResult = DOCK.checkMemoryUsage()
myMessage = 'Expected "3mb" to apear in : %s' % myResult
assert myResult is not None, 'Check memory reported None'
assert '3mb' in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:15,代码来源:test_dock.py
示例4: test_post_processor_output
def test_post_processor_output(self):
"""Check that the post processor does not add spurious report rows."""
# with KAB_NAME aggregation attribute defined in .keyword using
# kabupaten_jakarta_singlepart.shp
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function')
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
assert result, message
# Press RUN
DOCK.accept()
message = 'Spurious 0 filled rows added to post processing report.'
result = DOCK.wvResults.page().currentFrame().toPlainText()
for line in result.split('\n'):
if 'Entire area' in line:
tokens = str(line).split('\t')
tokens = tokens[1:]
total = 0
for token in tokens:
total += float(token.replace(',', '.'))
assert total != 0, message
开发者ID:FlavioFalcao,项目名称:inasafe,代码行数:31,代码来源:test_postprocessor_manager.py
示例5: test_checkAggregationAttributeNoneAttr
def test_checkAggregationAttributeNoneAttr(self):
"""Aggregation attribute is chosen correctly when there None in the
kezwords"""
myRunButton = DOCK.pbnRunStop
myFileList = ['kabupaten_jakarta_singlepart_with_None_keyword.shp']
#add additional layers
load_layers(myFileList, clear_flag=False, data_directory=TESTDATA)
myAttrKey = defaults('AGGR_ATTR_KEY')
# with None aggregation attribute defined in .keyword using
# kabupaten_jakarta_singlepart_with_None_keyword.shp
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart with None '
'keyword')
assert myResult, myMessage
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton)
DOCK.runtimeKeywordsDialog.accept()
myAttribute = DOCK.aggregator.attributes[myAttrKey]
myMessage = ('The aggregation should be None. Found: %s' % myAttribute)
assert myAttribute is None, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:27,代码来源:test_aggregator.py
示例6: test_checkAggregationAttributeInKW
def test_checkAggregationAttributeInKW(self):
"""Aggregation attribute is chosen correctly when present
in kezwords."""
myRunButton = DOCK.pbnRunStop
myAttrKey = defaults('AGGR_ATTR_KEY')
# with KAB_NAME aggregation attribute defined in .keyword using
# kabupaten_jakarta_singlepart.shp
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart',
aggregation_enabled_flag=True)
assert myResult, myMessage
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton)
DOCK.runtimeKeywordsDialog.accept()
myAttribute = DOCK.aggregator.attributes[myAttrKey]
myMessage = ('The aggregation should be KAB_NAME. Found: %s' %
myAttribute)
self.assertEqual(myAttribute, 'KAB_NAME', myMessage)
开发者ID:feyeandal,项目名称:inasafe,代码行数:25,代码来源:test_aggregator.py
示例7: test_check_aggregation_single_attribute
def test_check_aggregation_single_attribute(self):
"""Aggregation attribute is chosen correctly when there is only
one attr available."""
file_list = ['kabupaten_jakarta_singlepart_1_good_attr.shp']
# add additional layers
load_layers(file_list, clear_flag=False)
attribute_key = get_defaults('AGGR_ATTR_KEY')
# with 1 good aggregation attribute using
# kabupaten_jakarta_singlepart_1_good_attr.shp
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart 1 good attr')
set_jakarta_extent(dock=DOCK)
assert result, message
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
DOCK.runtime_keywords_dialog.accept()
print attribute_key
print DOCK.aggregator.attributes
attribute = DOCK.aggregator.attributes[attribute_key]
message = (
'The aggregation should be KAB_NAME. Found: %s' % attribute)
self.assertEqual(attribute, 'KAB_NAME', message)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:28,代码来源:test_aggregator.py
示例8: test_postProcessorOutput
def test_postProcessorOutput(self):
"""Check that the post processor does not add spurious report rows."""
myRunButton = DOCK.pbnRunStop
# with KAB_NAME aggregation attribute defined in .keyword using
# kabupaten_jakarta_singlepart.shp
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function')
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
assert myResult, myMessage
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton)
myMessage = 'Spurious 0 filled rows added to post processing report.'
myResult = DOCK.wvResults.page().currentFrame().toPlainText()
for line in myResult.split('\n'):
if 'Entire area' in line:
myTokens = str(line).split('\t')
myTokens = myTokens[1:]
mySum = 0
for myToken in myTokens:
mySum += float(myToken.replace(',', '.'))
assert mySum != 0, myMessage
开发者ID:gsuhartono,项目名称:inasafe,代码行数:33,代码来源:test_postprocessor_manager.py
示例9: test_issue306
def test_issue306(self):
"""Issue306: CANVAS doesnt add generated layers in tests
See https://github.com/AIFDR/inasafe/issues/306"""
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='Penduduk Jakarta',
function='HKVtest',
function_id='HKVtest')
self.assertTrue(result, message)
LOGGER.info("Canvas list before:\n%s" % canvas_list())
# Enable on-the-fly reprojection
set_canvas_crs(GOOGLECRS, True)
set_jakarta_google_extent()
before_count = len(CANVAS.layers())
#print 'Before count %s' % before_count
# Press RUN
DOCK.accept()
# test issue #306
after_count = len(CANVAS.layers())
LOGGER.info("Canvas list after:\n%s" % canvas_list())
message = ('Layer was not added to canvas (%s before, %s after)' % (
before_count, after_count))
#print 'After count %s' % after_count
self.assertTrue(before_count == after_count - 1, message)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:28,代码来源:test_dock.py
示例10: test_runCategorisedHazardPopulationImpactFunction
def test_runCategorisedHazardPopulationImpactFunction(self):
"""Flood function runs in GUI with Flood in Jakarta hazard data
Uses Penduduk Jakarta as exposure data."""
result, message = setup_scenario(
DOCK,
hazard='Flood in Jakarta',
exposure='Penduduk Jakarta',
function='Be impacted',
function_id='Categorised Hazard Population Impact Function')
self.assertTrue(result, message)
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
DOCK.accept()
result = DOCK.wvResults.page_to_text()
message = ('Result not as expected: %s' % result)
# This is the expected number of population might be affected
self.assertTrue(format_int(30938000) in result, message) # high
#self.assertTrue(format_int(68280000) in result, message)
#self.assertTrue(format_int(157551000) in result, message)
# The 2 asserts above are not valid anymore after the fix we made to
# CategorisedHazardPopulationImpactFunction
# Look at the fix here:
# (https://github.com/AIFDR/inasafe/commit/aa5b3d72145c031c91f4d101b830
# 8228915c248d#diff-378093670f4ebd60b4487af9b7c2e164)
# New Asserts
self.assertTrue(format_int(0) in result, message) # medium
self.assertTrue(format_int(256769000) in result, message) # low
开发者ID:D2KG,项目名称:FLOOgin,代码行数:33,代码来源:test_dock.py
示例11: test_runFloodPopulationImpactFunction_scaling
def test_runFloodPopulationImpactFunction_scaling(self):
"""Flood function runs in GUI with 5x5km population data
Raster on raster based function runs as expected with scaling."""
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function')
self.assertTrue(result, message)
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
button = DOCK.pbnRunStop
button.click()
result = DOCK.wvResults.page_to_text()
message = 'Result not as expected: %s' % result
# Check numbers are OK (within expected errors from resampling)
# These are expected impact number
self.assertTrue(format_int(10473000) in result, message)
self.assertTrue(format_int(978000) in result, message)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:27,代码来源:test_dock.py
示例12: Xtest_runnerExceptions
def Xtest_runnerExceptions(self):
"""Test runner exceptions"""
result, message = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Exception riser',
function_id='Exception Raising Impact Function',
aggregation_enabled_flag=True)
self.assertTrue(result, message)
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
# DOCK.runtime_keywords_dialog.accept()
expected_result = """Error:
An exception occurred when calculating the results
Problem:
Exception : AHAHAH I got you
Click for Diagnostic Information:
"""
result = DOCK.wvResults.page_to_text()
message = (
'The result message should be:\n%s\nFound:\n%s' %
(expected_result, result))
self.assertEqual(expected_result, result, message)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:30,代码来源:test_dock.py
示例13: Xtest_runnerIsNone
def Xtest_runnerIsNone(self):
"""Test for none runner exceptions"""
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='None returner',
function_id='None Returning Impact Function',
aggregation_enabled_flag=True)
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
# DOCK.runtimeKeywordsDialog.accept()
myExpectedResult = """Error:
An exception occurred when calculating the results
Problem:
AttributeError : 'NoneType' object has no attribute 'keywords'
Click for Diagnostic Information:
"""
myResult = DOCK.wvResults.page_to_text()
myMessage = ('The result message should be:\n%s\nFound:\n%s' %
(myExpectedResult, myResult))
self.assertEqual(myExpectedResult, myResult, myMessage)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py
示例14: test_checkAggregationAttribute1Attr
def test_checkAggregationAttribute1Attr(self):
"""Aggregation attribute is chosen correctly when there is only
one attr available."""
myFileList = ['kabupaten_jakarta_singlepart_1_good_attr.shp']
#add additional layers
load_layers(myFileList, clear_flag=False, data_directory=TESTDATA)
myAttrKey = breakdown_defaults('AGGR_ATTR_KEY')
# with 1 good aggregation attribute using
# kabupaten_jakarta_singlepart_1_good_attr.shp
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart 1 good attr')
assert myResult, myMessage
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
DOCK.runtimeKeywordsDialog.accept()
print myAttrKey
print DOCK.aggregator.attributes
myAttribute = DOCK.aggregator.attributes[myAttrKey]
myMessage = ('The aggregation should be KAB_NAME. Found: %s' %
myAttribute)
self.assertEqual(myAttribute, 'KAB_NAME', myMessage)
开发者ID:CharlesRethman,项目名称:inasafe,代码行数:28,代码来源:test_aggregator.py
示例15: test_issue581
def test_issue581(self):
"""Test issue #581 in github - Humanize can produce IndexError : list
index out of range
"""
# See https://github.com/AIFDR/inasafe/issues/581
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function')
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_small_jakarta_extent()
# Press RUN
DOCK.accept()
myResult = DOCK.wvResults.page().currentFrame().toPlainText()
myMessage = 'Result not as expected: %s' % myResult
assert 'IndexError' not in myResult, myMessage
assert 'It appears that no People are affected by A flood in ' \
'Jakarta like in 2007. You may want to consider:' in myResult
开发者ID:feyeandal,项目名称:inasafe,代码行数:25,代码来源:test_dock.py
示例16: test_fullRunResults
def test_fullRunResults(self):
"""Aggregation results are correct."""
myExpectedResult = open(
TEST_FILES_DIR +
'/test-full-run-results.txt',
'r').read()
myResult, myMessage = setup_scenario(
DOCK,
hazard='A flood in Jakarta like in 2007',
exposure='People',
function='Need evacuation',
function_id='Flood Evacuation Function',
aggregation_layer='kabupaten jakarta singlepart',
aggregation_enabled_flag=True)
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
DOCK.runtimeKeywordsDialog.accept()
myResult = DOCK.wvResults.page_to_text()
myMessage = ('The aggregation report should be:\n%s\n\nFound:\n\n%s' %
(myExpectedResult, myResult))
self.assertEqual(myResult, myExpectedResult, myMessage)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py
示例17: Xtest_printMap
def Xtest_printMap(self):
"""Test print map, especially on Windows."""
myResult, myMessage = setup_scenario(
DOCK,
hazard='Flood in Jakarta',
exposure='Essential buildings',
function='Be affected',
function_id='Categorised Hazard Building Impact Function')
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
myButton = DOCK.pbnRunStop
# noinspection PyCallByClass,PyTypeChecker
QTest.mouseClick(myButton, QtCore.Qt.LeftButton)
printButton = DOCK.pbnPrint
try:
# noinspection PyCallByClass,PyTypeChecker
QTest.mouseClick(printButton, QtCore.Qt.LeftButton)
except OSError:
LOGGER.debug('OSError')
# pass
except Exception, e:
raise Exception('Exception is not expected, %s' % e)
开发者ID:feyeandal,项目名称:inasafe,代码行数:29,代码来源:test_dock.py
示例18: test_issue45
def test_issue45(self):
"""Points near the edge of a raster hazard layer are interpolated OK"""
myButton = DOCK.pbnRunStop
set_canvas_crs(GEOCRS, True)
set_yogya_extent()
myMessage = 'Run button was not enabled'
assert myButton.isEnabled(), myMessage
myResult, myMessage = setup_scenario(
DOCK,
hazard='An earthquake in Yogyakarta like in 2006',
exposure='OSM Building Polygons',
function='Earthquake Guidelines Function',
function_id='Earthquake Guidelines Function')
assert myResult, myMessage
# This is the where nosetest sometims hangs when running the
# guitest suite (Issue #103)
# The QTest.mouseClick call some times never returns when run
# with nosetest, but OK when run normally.
# noinspection PyCallByClass,PyTypeChecker
DOCK.accept()
myResult = DOCK.wvResults.page_to_text()
# Check that none of these get a NaN value:
self.assertIn('Unknown', myResult)
myMessage = ('Some buildings returned by Earthquake guidelines '
'function '
'had NaN values. Result: \n %s' % myResult)
assert 'Unknown (NaN): 196' not in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:33,代码来源:test_dock.py
示例19: test_runCategorisedHazardPopulationImpactFunction
def test_runCategorisedHazardPopulationImpactFunction(self):
"""Flood function runs in GUI with Flood in Jakarta hazard data
Uses Penduduk Jakarta as exposure data."""
myResult, myMessage = setup_scenario(
DOCK,
hazard='Flood in Jakarta',
exposure='Penduduk Jakarta',
function='Be impacted',
function_id='Categorised Hazard Population Impact Function')
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_jakarta_extent()
# Press RUN
DOCK.accept()
myResult = DOCK.wvResults.page_to_text()
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of population might be affected
assert format_int(30938000) in myResult, myMessage
assert format_int(68280000) in myResult, myMessage
assert format_int(157551000) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:25,代码来源:test_dock.py
示例20: test_runEarthquakeBuildingImpactFunction
def test_runEarthquakeBuildingImpactFunction(self):
"""Earthquake function runs in GUI with An earthquake in Yogyakarta
like in 2006 hazard data uses OSM Building Polygons exposure data."""
myResult, myMessage = setup_scenario(
DOCK,
hazard='An earthquake in Yogyakarta like in 2006',
exposure='OSM Building Polygons',
function='Be affected',
function_id='Earthquake Building Impact Function')
assert myResult, myMessage
# Enable on-the-fly reprojection
set_canvas_crs(GEOCRS, True)
set_geo_extent([101, -12, 119, -4])
# Press RUN
DOCK.accept()
myResult = DOCK.wvResults.page_to_text()
LOGGER.debug(myResult)
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of building might be affected
assert format_int(786) in myResult, myMessage
assert format_int(15528) in myResult, myMessage
assert format_int(177) in myResult, myMessage
开发者ID:feyeandal,项目名称:inasafe,代码行数:26,代码来源:test_dock.py
注:本文中的safe_qgis.utilities.utilities_for_testing.setup_scenario函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论