def test_empty_observer(self): toolOutput = None # Check for empty target input parameter with self.assertRaises(arcpy.ExecuteError) as manage_raise: toolOutput = arcpy.LinearLineOfSight_mt( self.observers, 2.0, self.targets_empty, 0.0, self.inputSurface, self.outputLOS, self.outputSightLines, self.outputObservers, self.outputTargets) self.assertTrue("Please provide at least one target feature" in str( manage_raise.exception)) return
def test_linear_line_of_sight_desktop(self): ''' Test Linear Line Of Sight in ArcGIS Desktop''' runToolMessage = ".....LinearLineOfSightTestCase.test_linear_line_of_sight_desktop" arcpy.env.overwriteOutput = True arcpy.ImportToolbox(Configuration.military_DesktopToolboxPath, "mt") arcpy.AddMessage(runToolMessage) Configuration.Logger.info(runToolMessage) arcpy.LinearLineOfSight_mt(self.observers, 2.0, self.targets, 0.0, self.inputSurface, self.outputLOS, self.outputSightLines, self.outputObservers, self.outputTargets) self.assertTrue(arcpy.Exists(self.outputLOS), "Output LOS does not exist or was not created") self.assertTrue(arcpy.Exists(self.outputSightLines), "Output Sight Lines to not exist or were not created") self.assertTrue(arcpy.Exists(self.outputObservers), "Output Observers do not exist or were not created") self.assertTrue(arcpy.Exists(self.outputTargets), "Output Targets do not exist or were not created") featureCount = int( arcpy.GetCount_management(self.outputLOS).getOutput(0)) expectedFeatures = int(32) self.assertEqual( featureCount, expectedFeatures, "Expected %s features but got %s" % (str(expectedFeatures), str(featureCount))) featureCountSightLines = int( arcpy.GetCount_management(self.outputSightLines).getOutput(0)) self.assertEqual( featureCountSightLines, int(16), "Expected 16 Sight Lines but got {0}".format( featureCountSightLines)) expectedObserverCount = int( arcpy.GetCount_management(self.observers).getOutput(0)) * 4 actualObserverCount = int( arcpy.GetCount_management(self.outputObservers).getOutput(0)) self.assertEqual( expectedObserverCount, actualObserverCount, "Expected {0} observers but got {1}".format( expectedObserverCount, actualObserverCount)) expectedTargetCount = int( arcpy.GetCount_management(self.targets).getOutput(0)) * 4 actualTargetCount = int( arcpy.GetCount_management(self.outputTargets).getOutput(0)) self.assertEqual( expectedTargetCount, actualTargetCount, "Expected {0} targets but got {1}".format(expectedTargetCount, actualTargetCount)) #TODO: check attached profile graphs were created return
def test_linear_line_of_sight(self): ''' Test Linear Line Of Sight in ArcGIS Desktop''' Configuration.Logger.info( ".....LinearLineOfSightTestCase.test_linear_line_of_sight") arcpy.env.overwriteOutput = True toolOutput = None try: toolOutput = arcpy.LinearLineOfSight_mt( self.observers, 2.0, self.targets, 0.0, self.inputSurface, self.outputLOS, self.outputSightLines, self.outputObservers, self.outputTargets) except: # WORKAROUND: To arpy exception with Pro: # "DeprecationWarning: Product and extension licensing is no longer handled with this method." # when this tool is run in Pro from unit test driver if (Configuration.Platform == Configuration.PLATFORM_PRO): pass # WORKAROUND: see above - toolOutput not being set because of exception on return if (Configuration.Platform != Configuration.PLATFORM_PRO): # 1: Check the expected return value self.assertIsNotNone(toolOutput, "No output returned from tool") outputLineOfSightOut = toolOutput.getOutput(0) outputSightLinesOut = toolOutput.getOutput(1) outputObserversOut = toolOutput.getOutput(2) outputTargetsOut = toolOutput.getOutput(3) self.assertEqual(self.outputLOS, outputLineOfSightOut, "Unexpected return value from tool") self.assertEqual(self.outputSightLines, outputSightLinesOut, "Unexpected return value from tool") self.assertEqual(self.outputObservers, outputObserversOut, "Unexpected return value from tool") self.assertEqual(self.outputTargets, outputTargetsOut, "Unexpected return value from tool") # 2: Verify output was created self.assertTrue(arcpy.Exists(self.outputLOS), "Output LOS does not exist or was not created") self.assertTrue(arcpy.Exists(self.outputSightLines), "Output Sight Lines to not exist or were not created") self.assertTrue(arcpy.Exists(self.outputObservers), "Output Observers do not exist or were not created") self.assertTrue(arcpy.Exists(self.outputTargets), "Output Targets do not exist or were not created") featureCount = int( arcpy.GetCount_management(self.outputLOS).getOutput(0)) expectedFeatures = int(32) self.assertEqual( featureCount, expectedFeatures, "Expected %s features but got %s" % (str(expectedFeatures), str(featureCount))) featureCountSightLines = int( arcpy.GetCount_management(self.outputSightLines).getOutput(0)) self.assertEqual( featureCountSightLines, int(16), "Expected 16 Sight Lines but got {0}".format( featureCountSightLines)) expectedObserverCount = int( arcpy.GetCount_management(self.observers).getOutput(0)) * 4 actualObserverCount = int( arcpy.GetCount_management(self.outputObservers).getOutput(0)) self.assertEqual( expectedObserverCount, actualObserverCount, "Expected {0} observers but got {1}".format( expectedObserverCount, actualObserverCount)) expectedTargetCount = int( arcpy.GetCount_management(self.targets).getOutput(0)) * 4 actualTargetCount = int( arcpy.GetCount_management(self.outputTargets).getOutput(0)) self.assertEqual( expectedTargetCount, actualTargetCount, "Expected {0} targets but got {1}".format(expectedTargetCount, actualTargetCount)) #TODO: check attached profile graphs were created return