当前位置: 首页>>代码示例>>Python>>正文


Python UnitTestUtilities类代码示例

本文整理汇总了Python中UnitTestUtilities的典型用法代码示例。如果您正苦于以下问题:Python UnitTestUtilities类的具体用法?Python UnitTestUtilities怎么用?Python UnitTestUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UnitTestUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     if Configuration.DEBUG == True: print("     SubSpecificationsTestCase.setUp")
 
     UnitTestUtilities.checkArcPy()
     self.maritimeDataGDB = os.path.join(Configuration.maritimeDataPath, "Maritime Decision Aid Tools.gdb")
     self.subSpecsTable = os.path.join(self.maritimeDataGDB, "Sub_Specs")
     UnitTestUtilities.checkFilePaths([Configuration.maritimeDataPath, Configuration.maritime_DesktopToolboxPath, Configuration.maritime_ProToolboxPath])
开发者ID:NatalieCampos,项目名称:solutions-geoprocessing-toolbox,代码行数:7,代码来源:SubSpecificationsTestCase.py

示例2: test_incident_table_to_point

 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()
         
开发者ID:weepingdog,项目名称:solutions-geoprocessing-toolbox,代码行数:26,代码来源:IncidentTableToPointTestCase.py

示例3: test_cluster_analysis

    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))
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:29,代码来源:ClusterAnalysisTestCase.py

示例4: test_hot_spots_by_area

 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()
         
         
开发者ID:weepingdog,项目名称:solutions-geoprocessing-toolbox,代码行数:24,代码来源:HotSpotsByAreaTestCase.py

示例5: main

def main():
    ''' main test logic '''
    if Configuration.DEBUG == True:
        print("TestRunner.py - main")
    else:
        print("Debug messaging is OFF")

    # setup logger
    logName = None
    if not logFileFromBAT == None:
        logName = logFileFromBAT
        Configuration.Logger = UnitTestUtilities.initializeLogger(logFileFromBAT)
    else:
        logName = UnitTestUtilities.getLoggerName()
        Configuration.Logger = UnitTestUtilities.initializeLogger(logName)
    print("Logging results to: " + str(logName))
    UnitTestUtilities.setUpLogFileHeader()

    result = runTestSuite()
    logTestResults(result)
    print("END OF TEST =========================================\n")

    if result.wasSuccessful():
        #tests successful
        sys.exit(0)
    else:
        # test errors or failures
        sys.exit(1)

    return
开发者ID:Esri,项目名称:solutions-webappbuilder-widgets,代码行数:30,代码来源:TestRunner.py

示例6: testClearingOperationsNumberFeatures_NoOutputParam

    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,代码行数:60,代码来源:ClearingOperationsNumberFeaturesTestCase.py

示例7: main

def main():
    ''' main test logic '''
    print("TestRunner.py - main")

    if Configuration.DEBUG == True:
        print("Debug messaging is ON")
        logLevel = logging.DEBUG
    else:
        print("Debug messaging is OFF")
        logLevel = logging.INFO

    # setup logger
    if not logFileFromBAT == None:
        Configuration.Logger = UnitTestUtilities.initializeLogger(logFileFromBAT, logLevel)
    else:
        Configuration.GetLogger(logLevel)

    print("Logging results to: " + str(Configuration.LoggerFile))
    UnitTestUtilities.setUpLogFileHeader()

    result = runTestSuite()

    logTestResults(result)

    return result.wasSuccessful()
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:25,代码来源:TestRunner.py

示例8: setUp

    def setUp(self):
        if Configuration.DEBUG == True: print("     SubsetRasterWorkspaceTestCase.setUp")
        UnitTestUtilities.checkArcPy()

        # DO NOT run data download again; dependent data is needed from ImportCRUToRasterTestCase
        self.sourceWorkspace = os.path.join(Configuration.suitabilityDataPath, "CRURasters.gdb")
        self.targetWorkspace = os.path.join(Configuration.suitabilityDataPath, "SubsetRasters.gdb")
        
        UnitTestUtilities.checkFilePaths([Configuration.suitabilityDataPath, Configuration.maow_ToolboxPath, self.sourceWorkspace, self.targetWorkspace])
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:9,代码来源:SubsetRasterWorkspaceTestCase.py

示例9: setUp

    def setUp(self):
        if Configuration.DEBUG == True: print("     ImportCRUToRasterTestCase.setUp")
        UnitTestUtilities.checkArcPy()

        Configuration.suitabilityDataPath = DataDownload.runDataDownload(Configuration.suitabilityPaths, "MilitaryAspectsOfWeatherTestData", Configuration.maowURL)
        self.inputCRUFolder = os.path.join(Configuration.suitabilityDataPath, "CRUdata")
        self.outputWorkspace = os.path.join(Configuration.suitabilityDataPath, "CRURasters.gdb")
       
        UnitTestUtilities.checkFilePaths([Configuration.suitabilityDataPath, Configuration.maow_ToolboxPath, self.outputWorkspace])
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:9,代码来源:ImportCRUToRasterTestCase.py

示例10: setUp

 def setUp(self):
     if Configuration.DEBUG == True: print("     FindSubmarinesTestCase.setUp")
         
     UnitTestUtilities.checkArcPy()
     Configuration.maritimeDataPath = DataDownload.runDataDownload(Configuration.suitabilityPaths, Configuration.maritimeGDBName, Configuration.maritimeURL)
     if(Configuration.maritimeScratchGDB == None) or (not arcpy.Exists(Configuration.maritimeScratchGDB)):
         Configuration.maritimeScratchGDB = UnitTestUtilities.createScratch(Configuration.maritimeDataPath)
         
     self.useableCanyons = os.path.join(Configuration.maritimeScratchGDB, "canyonsOutput")
     UnitTestUtilities.checkFilePaths([Configuration.maritimeDataPath, Configuration.maritime_DesktopToolboxPath, Configuration.maritime_ProToolboxPath])
开发者ID:NatalieCampos,项目名称:solutions-geoprocessing-toolbox,代码行数:10,代码来源:FindSubmarinesTestCase.py

示例11: setUp

 def setUp(self):
     if Configuration.DEBUG == True: print(".....IncidentHotSpotsTestCase.setUp")    
     UnitTestUtilities.checkArcPy()
     Configuration.incidentDataPath = DataDownload.runDataDownload(Configuration.patternsPaths, Configuration.incidentGDBName, Configuration.incidentURL)
     if (Configuration.incidentScratchGDB == None) or (not arcpy.Exists(Configuration.incidentScratchGDB)):
         Configuration.incidentScratchGDB = UnitTestUtilities.createScratch(Configuration.incidentDataPath)
     Configuration.incidentInputGDB = os.path.join(Configuration.incidentDataPath, Configuration.incidentGDBName)
     UnitTestUtilities.checkFilePaths([Configuration.incidentDataPath, Configuration.incidentInputGDB, Configuration.patterns_ProToolboxPath, Configuration.patterns_DesktopToolboxPath])
     self.inputPointFeatures = os.path.join(Configuration.incidentInputGDB, "Incidents")
     self.inputBoundaryFeatures = os.path.join(Configuration.incidentInputGDB, "Districts")
开发者ID:NatalieCampos,项目名称:solutions-geoprocessing-toolbox,代码行数:10,代码来源:IncidentHotSpotsTestCase.py

示例12: GetLogger

def GetLogger(logLevel = logging.DEBUG) :

    global Logger

    if Logger is None:

        import UnitTestUtilities

        logName = UnitTestUtilities.getLoggerName()
        Logger = UnitTestUtilities.initializeLogger(logName, logLevel)

    return Logger
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:12,代码来源:Configuration.py

示例13: setUp

 def setUp(self):
     if Configuration.DEBUG == True: print("     SubDepthRestrictionSuitabilityTestCase.setUp")
         
     UnitTestUtilities.checkArcPy()
     Configuration.maritimeDataPath = DataDownload.runDataDownload(Configuration.suitabilityPaths, Configuration.maritimeGDBName, Configuration.maritimeURL)
     if(Configuration.maritimeScratchGDB == None) or (not arcpy.Exists(Configuration.maritimeScratchGDB)):
         Configuration.maritimeScratchGDB = UnitTestUtilities.createScratch(Configuration.maritimeDataPath)
         
     self.maritimeDataGDB = os.path.join(Configuration.maritimeDataPath, "Maritime Decision Aid Tools.gdb")
     
     self.bathymetry = os.path.join(self.maritimeDataGDB, "SoCalDepthsGEBCO")
     self.subDepthOutput = os.path.join(Configuration.maritimeScratchGDB, "SubDepth")
     UnitTestUtilities.checkFilePaths([Configuration.maritimeDataPath, Configuration.maritime_DesktopToolboxPath, Configuration.maritime_ProToolboxPath])
开发者ID:NatalieCampos,项目名称:solutions-geoprocessing-toolbox,代码行数:13,代码来源:SubDepthRestrictionSuitabilityTestCase.py

示例14: setUp

    def setUp(self):
        if Configuration.DEBUG == True: print("     FarthestOnCircleTestCase.setUp")    
        
        UnitTestUtilities.checkArcPy()
        Configuration.maritimeDataPath = DataDownload.runDataDownload(Configuration.suitabilityPaths, Configuration.maritimeGDBName, Configuration.maritimeURL)
        if(Configuration.maritimeScratchGDB == None) or (not arcpy.Exists(Configuration.maritimeScratchGDB)):
            Configuration.maritimeScratchGDB = UnitTestUtilities.createScratch(Configuration.maritimeDataPath)
            
        self.maritimeDataGDB = os.path.join(Configuration.maritimeDataPath, "Maritime Decision Aid Tools.gdb")

        self.position = os.path.join(self.maritimeDataGDB, "Vessel")
        self.hoursOfTransit = os.path.join(Configuration.maritimeScratchGDB, "hoursOutput")
        UnitTestUtilities.checkFilePaths([Configuration.maritimeDataPath, Configuration.maritime_DesktopToolboxPath, Configuration.maritime_ProToolboxPath])
开发者ID:NatalieCampos,项目名称:solutions-geoprocessing-toolbox,代码行数:13,代码来源:FarthestOnCircleTestCase.py

示例15: test_sub_depth_restriction_suitability

 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,代码行数:14,代码来源:SubDepthRestrictionSuitabilityTestCase.py


注:本文中的UnitTestUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。