本文整理汇总了Python中UnitTestUtilities.handleGeneralError方法的典型用法代码示例。如果您正苦于以下问题:Python UnitTestUtilities.handleGeneralError方法的具体用法?Python UnitTestUtilities.handleGeneralError怎么用?Python UnitTestUtilities.handleGeneralError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTestUtilities
的用法示例。
在下文中一共展示了UnitTestUtilities.handleGeneralError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hot_spots_by_area
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_hot_spots_by_area(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" HotSpotsByAreaTestCase.test_hot_spots_by_area")
arcpy.ImportToolbox(toolboxPath, "iaTools")
runToolMessage = "Running tool (Hot Spots By Area)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
incidentFieldName = "district"
outputWorkspace = Configuration.incidentDataPath
# second parameter: inputIncidents must be a Feature Layer
arcpy.MakeFeatureLayer_management(self.inputIncidents, "incidentsLayer")
arcpy.HotSpotsByArea_iaTools(self.inputAOIFeatures, "incidentsLayer", incidentFieldName, outputWorkspace)
self.assertTrue(arcpy.Exists(outputWorkspace))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例2: test_cluster_analysis
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_cluster_analysis(self):
'''test_cluster_analysis'''
if Configuration.DEBUG == True: print(".....ClusterAnalysisTestCase.test_cluster_analysis")
arcpy.ImportToolbox(self.toolboxUnderTest, self.toolboxUnderTestAlias)
outputClusterFeatures = os.path.join(Configuration.incidentResultGDB, "outputClusters")
# Delete the feature class used to load if already exists
if arcpy.Exists(outputClusterFeatures) :
arcpy.Delete_management(outputClusterFeatures)
runToolMessage = "Running tool (Cluster Analysis)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
distance = "500 Meters"
try:
# Tools have different parameter order in Pro vs. ArcMap
if Configuration.Platform == Configuration.PLATFORM_PRO :
arcpy.ClusterAnalysis_iaTools(self.inputPointsFeatures, distance, outputClusterFeatures)
else:
arcpy.ClusterAnalysis_iaTools(self.inputPointsFeatures, outputClusterFeatures, distance)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except Exception as e:
UnitTestUtilities.handleGeneralError(e)
clusterCount = int(arcpy.GetCount_management(outputClusterFeatures).getOutput(0))
self.assertGreaterEqual(clusterCount, int(10))
示例3: test_incident_table_to_point
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_incident_table_to_point(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" IncidentTableToPointTestCase.test_incident_table_to_point")
arcpy.ImportToolbox(toolboxPath, "iaTools")
runToolMessage = "Running tool (Incident Table To Point)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
coordFormat = "MGRS"
xField = "MGRS"
yField = "MGRS"
outputTable = os.path.join(Configuration.incidentScratchGDB, "outputTable")
arcpy.IncidentTableToPoint_iaTools(self.inputTable, coordFormat, xField, yField, outputTable)
result = arcpy.GetCount_management(outputTable)
featureCount = int(result.getOutput(0))
self.assertEqual(featureCount, int(5532))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例4: testClearingOperationsNumberFeatures_NoOutputParam
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def testClearingOperationsNumberFeatures_NoOutputParam(self):
if Configuration.DEBUG == True:print(".....ClearingOperationsNumberFeaturesTestCase.testClearingOperationsNumberFeatures_NoOutputParam")
print("Importing toolbox...")
arcpy.ImportToolbox(self.toolboxUnderTest)
arcpy.env.overwriteOutput = True
########################################################
# Test steps:
# 1. Copy a known feature class in the AOI to the scratch GDB
# 2. Add a new "Number" field (so will be blank)
# 3. Run the NumberFeatures tool
# 4. Verify the output
########################################################
#inputs
fieldToNumber = "NumberNewField"
inputPoints = os.path.join(self.scratchGDB, 'numFieldsInput_NoOutput')
# Copy the features of the original input FC into the scratch GDB
arcpy.CopyFeatures_management(self.pointFeatures, inputPoints)
arcpy.AddField_management(inputPoints, fieldToNumber, "LONG")
# Start Test
runToolMsg="Running tool (Number Features)"
arcpy.AddMessage(runToolMsg)
Configuration.Logger.info(runToolMsg)
toolOutput = None
try:
#Calling the NumberFeatures_ClearingOperations Script Tool
#No output parameter
toolOutput = arcpy.NumberFeatures_clrops(self.inputArea, inputPoints, \
fieldToNumber)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
# 1: Check the expected return value (output feature class)
# TODO: this return value may change in the future, and this check may need updated
expectedOutput = ""
if toolOutput is None:
returnedValue = "BAD"
else:
returnedValue = toolOutput.getOutput(0)
self.assertEqual(returnedValue, expectedOutput)
#2: Check the Output Feature class has no rows without a null Number
outputLayer = "Number_NoOutput"
arcpy.MakeFeatureLayer_management(inputPoints, outputLayer)
query = '(' + fieldToNumber + ' is NOT NULL)'
arcpy.SelectLayerByAttribute_management(outputLayer, "NEW_SELECTION", query)
recordCount = int(arcpy.GetCount_management(outputLayer).getOutput(0))
# Important only 90 of 120 records are in the area of interest
self.assertEqual(recordCount, int(90))
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:62,代码来源:ClearingOperationsNumberFeaturesTestCase.py
示例5: test_sub_depth_restriction_suitability
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_sub_depth_restriction_suitability(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" SubDepthRestrictionSuitabilityTestCase.test_sub_depth_restriction_suitability")
runToolMessage = "Running tool (Sub Depth Restriction Suitability)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
开发者ID:weepingdog,项目名称:solutions-geoprocessing-toolbox,代码行数:16,代码来源:SubDepthRestrictionSuitabilityTestCase.py
示例6: test_sub_specifications
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_sub_specifications(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" SubSpecificationsTestCase.test_sub_specifications")
runToolMessage = "Running tool (Sub Specifications)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例7: testClearingOperationsNumberFeatures
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def testClearingOperationsNumberFeatures(self):
if Configuration.DEBUG == True:print(".....ClearingOperationsNumberFeaturesTestCase.testClearingOperationsNumberFeatures")
print("Importing toolbox...")
arcpy.ImportToolbox(self.toolboxUnderTest)
arcpy.env.overwriteOutput = True
#inputs
fieldToNumber = "Number"
output = os.path.join(self.scratchGDB, "numFields")
# Start Test
runToolMsg="Running tool (Number Features)"
arcpy.AddMessage(runToolMsg)
Configuration.Logger.info(runToolMsg)
toolOutput = None
try:
#Calling the NumberFeatures_ClearingOperations Script Tool
toolOutput = arcpy.NumberFeatures_clrops(self.inputArea, self.pointFeatures, fieldToNumber, output)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
# 1: Check the expected return value (output feature class)
if toolOutput is None:
returnedValue = "BAD"
else:
returnedValue = toolOutput.getOutput(0)
self.assertEqual(returnedValue, output)
# 2: Check the number of records
result = arcpy.GetCount_management(output)
count = int(result.getOutput(0))
# print("number features: " + str(count))
# Important only 90 of 120 records are in the area of interest
self.assertEqual(count, 90)
# 3: Check that the "number" field was created/updated for each row
cursor = arcpy.SearchCursor(output)
row = cursor.next()
while row is not None:
val = row.getValue(fieldToNumber)
# Debug: print("Field number first row: " + str(val) + " should not be null")
self.assertIsNotNone(val)
row = cursor.next()
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:49,代码来源:ClearingOperationsNumberFeaturesTestCase.py
示例8: test_local_peaks
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_local_peaks(self):
try:
arcpy.AddMessage("Testing Find Local Peaks (unit).")
if arcpy.CheckExtension("Spatial") == "Available":
arcpy.CheckOutExtension("Spatial")
else:
raise Exception("LicenseError")
print("Importing Visibility and Range Toolbox...")
arcpy.ImportToolbox(Configuration.visandRangeToolbox, "VandR")
arcpy.env.overwriteOutput = True
inputFeatureCount = int(arcpy.GetCount_management(self.inputPolygonFC).getOutput(0))
print("Input FeatureClass: " + str(self.inputPolygonFC))
print("Input Feature Count: " + str(inputFeatureCount))
self.assertTrue(inputFeatureCount > 0)
# if (inputFeatureCount < 1):
# print("Invalid Input Feature Count: " + str(inputFeatureCount))
numberOfPeaks = 3
########################################################
# Execute the Model under test:
arcpy.FindLocalPeaks_VandR(self.inputPolygonFC, numberOfPeaks, self.inputSurface, self.outputPointsFC)
########################################################
# Verify the results
outputFeatureCount = int(arcpy.GetCount_management(self.outputPointsFC).getOutput(0))
print("Output FeatureClass: " + str(self.outputPointsFC))
print("Output Feature Count: " + str(outputFeatureCount))
self.assertEqual(outputFeatureCount, 3)
# if (outputPointsFC < 3):
# print("Invalid Output Feature Count: " + str(outputFeatureCount))
# raise Exception("Test Failed")
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
finally:
arcpy.CheckInExtension("Spatial")
示例9: test_hot_spots_by_area
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_hot_spots_by_area(self):
'''test_hot_spots_by_area'''
if Configuration.DEBUG == True: print(".....HotSpotsByAreaTestCase.test_hot_spots_by_area")
arcpy.env.overwriteOutput = True
arcpy.ImportToolbox(self.toolboxUnderTest, self.toolboxUnderTestAlias)
runToolMessage = "Running tool (Hot Spots By Area)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
incidentFieldName = "district"
outputWorkspace = self.incidentScratchGDB
results = None
try:
# second parameter: inputIncidents must be a Feature Layer
layerName = "incidentsLayer"
arcpy.MakeFeatureLayer_management(self.inputIncidents, layerName)
# Tools have slightly different names in Pro vs. ArcMap ("By" vs. "by")
if Configuration.Platform == Configuration.PLATFORM_PRO :
results = arcpy.HotSpotsByArea_iaTools(self.inputAOIFeatures, layerName, \
incidentFieldName, outputWorkspace)
else:
# WORKAROUND:
# ArcMap version of tool ignores outputWorkspace parameter
arcpy.env.scratchWorkspace = outputWorkspace
arcpy.env.workspace = outputWorkspace
# End WORKAROUNG
results = arcpy.HotSpotsbyArea_iaTools(self.inputAOIFeatures, layerName, \
incidentFieldName, outputWorkspace)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except Exception as e:
UnitTestUtilities.handleGeneralError(e)
self.assertIsNotNone(results)
outputFeatureClasses = results[0].split(';')
for outputFeatureClass in outputFeatureClasses:
self.assertTrue(arcpy.Exists(outputFeatureClass))
示例10: test_import_wmo_station_data
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_import_wmo_station_data(self):
try:
if Configuration.DEBUG == True: print(" ImportWMOStationDataTestCase.test_import_wmo_station_data")
arcpy.AddMessage("Testing Import WMO Station Data (Desktop)")
arcpy.ImportToolbox(Configuration.maow_ToolboxPath, "maow")
runToolMessage = "Running tool (Import WMO Station Data)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
arcpy.ImportWMOStationData_maow(self.WMOGDB, self.outputFCName, self.WMOFolder, self.StationDataInputFC)
wmoStationCount = int(arcpy.GetCount_management(self.StationDataOutputFC).getOutput(0))
self.assertEqual(wmoStationCount, int(252))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例11: test_incident_hot_spots
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_incident_hot_spots(self):
'''test_incident_hot_spots'''
if Configuration.DEBUG == True: print(".....IncidentHotSpotsTestCase.test_incident_hot_spots")
arcpy.ImportToolbox(self.toolboxUnderTest, self.toolboxUnderTestAlias)
runToolMessage = "Running tool (Incident Hot Spots)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
outputFeatures = os.path.join(Configuration.incidentResultGDB, "outputHotSpots")
# Delete the feature class used to load if already exists
if arcpy.Exists(outputFeatures) :
arcpy.Delete_management(outputFeatures)
try:
if Configuration.Platform == Configuration.PLATFORM_PRO :
# Pro requires these to be layers
incidentsLayer = arcpy.MakeFeatureLayer_management(self.inputPointFeatures)
boundariesLayer = arcpy.MakeFeatureLayer_management(self.inputBoundaryFeatures)
arcpy.IncidentHotSpots_iaTools(incidentsLayer, boundariesLayer, outputFeatures)
else:
# Note: ArcMap has different parameter order
arcpy.IncidentHotSpots_iaTools(self.inputPointFeatures, outputFeatures, \
self.inputBoundaryFeatures)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except Exception as e:
UnitTestUtilities.handleGeneralError(e)
result = arcpy.GetCount_management(outputFeatures)
featureCount = int(result.getOutput(0))
print("Number of features in output: " + str(featureCount))
# Note: Pro and ArcMap returning different counts (4200 vs. 7400)
self.assertGreater(featureCount, int(4000))
示例12: testClearingOperationsPointTarget
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def testClearingOperationsPointTarget(self):
if Configuration.DEBUG == True:print(".....ClearingOperationsCreateGRGFromPointTestCase.testClearingOperationsPointTarget")
print("Importing toolbox...")
arcpy.ImportToolbox(self.toolboxUnderTest)
arcpy.env.overwriteOutput = True
#inputs
numCellsH = 9
numCellsV = 9
cellWidth = 100
cellHeight = 100
cellUnits = "Meters"
labelStart = "Lower-Left"
labelStyle = "Alpha-Numeric"
labelSeparator = "-" # Only used for Alpha-Alpha but required parameter?
gridRotationAngle = 0
output = os.path.join(self.scratchGDB, "ptTarget")
#Testing
runToolMsg="Running tool (Point Target)"
arcpy.AddMessage(runToolMsg)
Configuration.Logger.info(runToolMsg)
try:
# Calling the PointTargetGRG_ClearingOperations Script Tool
arcpy.CreateGRGFromPoint_clrops(self.pointTarget, \
numCellsH, numCellsV, \
cellWidth, cellHeight, "Meters", \
labelStart, labelStyle, labelSeparator, gridRotationAngle, \
output)
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
result = arcpy.GetCount_management(output)
count = int(result.getOutput(0))
print("number features: " + str(count))
self.assertGreaterEqual(count, 80)
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:43,代码来源:ClearingOperationsCreateGRGFromPointTestCase.py
示例13: test_cluster_analysis
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_cluster_analysis(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" ClusterAnalysisTestCase.test_cluster_analysis")
arcpy.ImportToolbox(toolboxPath, "iaTools")
outputClusterFeatures = os.path.join(Configuration.incidentScratchGDB, "outputClusters")
runToolMessage = "Running tool (Cluster Analysis)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
# arcpy.ClusterAnalysis_iaTools(self.inputPointsFeatures, Output_Cluster_Features=outputClusterFeatures)
arcpy.ClusterAnalysis_iaTools(self.inputPointsFeatures, "#", outputClusterFeatures)
clusterCount = int(arcpy.GetCount_management(outputClusterFeatures).getOutput(0))
self.assertEqual(clusterCount, int(37))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例14: test_incident_hot_spots
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_incident_hot_spots(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" IncidentHotSpotsTestCase.test_incident_hot_spots")
arcpy.ImportToolbox(toolboxPath, "iaTools")
runToolMessage = "Running tool (Incident Hot Spots)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
outputFeatures = os.path.join(Configuration.incidentScratchGDB, "outputHotSpots")
arcpy.IncidentHotSpots_iaTools(self.inputPointFeatures, self.inputBoundaryFeatures, outputFeatures)
result = arcpy.GetCount_management(outputFeatures)
featureCount = int(result.getOutput(0))
self.assertEqual(featureCount, int(7302))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
示例15: test_find_submarine
# 需要导入模块: import UnitTestUtilities [as 别名]
# 或者: from UnitTestUtilities import handleGeneralError [as 别名]
def test_find_submarine(self, toolboxPath):
try:
if Configuration.DEBUG == True: print(" FindSubmarinesTestCase.test_find_submarine")
arcpy.ImportToolbox(toolboxPath, "mdat")
runToolMessage = "Running tool (Find Submarines)"
arcpy.AddMessage(runToolMessage)
Configuration.Logger.info(runToolMessage)
arcpy.CheckOutExtension("Spatial")
arcpy.UseableSubmarineCanyons_mdat("#", "#", "#", self.useableCanyons)
self.assertTrue(arcpy.Exists(self.useableCanyons))
except arcpy.ExecuteError:
UnitTestUtilities.handleArcPyError()
except:
UnitTestUtilities.handleGeneralError()
finally:
arcpy.CheckInExtension("Spatial")