Esri / solutions-geoprocessing-toolbox

Models, scripts, and tools for use in ArcGIS Desktop and Server to support defense and intelligence workflows.
Apache License 2.0
133 stars 69 forks source link

Tests (Pro & Desktop) fail with space in path #571

Closed mfunk closed 6 years ago

mfunk commented 7 years ago

As of 8/11/2017 Jenkins tests are failing with a space in the path names.

Pro (Desktop similar) test results:

...
...
...
Test success: False

RESULTS =================================================
Number of tests run: 12
Number succeeded: 10
Number of errors: 1
Number of failures: 1
Number of tests skipped: 0
Percent passing: 83.3
=========================================================

ERRORS ==================================================
test_create_geonames_gazetteer (geonames_tests.GeoNamesTestCase.GeoNamesTestCase)
Traceback (most recent call last):
  File "D:\GitHub\solutions geoprocessing toolbox\utils\test\geonames_tests\GeoNamesTestCase.py", line 114, in test_create_geonames_gazetteer
    arcpy.CreateGeonamesGazetteerLocator_defensegeonames(locatorFeatureClass, locator)
  File "D:\GitHub\solutions geoprocessing toolbox\geonames\Geonames Tools_pro.tbx", line 32, in CreateGeonamesGazetteerLocator
       A D M I N 1 C O D E
  File "D:\GitHub\solutions geoprocessing toolbox\geonames\Geonames Tools_pro.tbx", line 29, in CreateGeonamesGazetteerLocator
       A D I _ A S C I I N
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000811: The value is not a feature class
ERROR 000800: The value is not a member of Primary Table | Alias Table.
WARNING 000725: Output Geonames Gazetteer Locator: Dataset D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\GeoNamesLocator already exists.
The value does not exist.
ERROR 000039: Not enough reference data tables for this style.
WARNING 000725: Output Address Locator: Dataset D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\GeoNamesLocator already exists.
Failed to execute (CreateGeonamesGazetteerLocator).
FAILURES ================================================
test_hot_spots_by_area (incident_analysis_tests.HotSpotsByAreaTestCase.HotSpotsByAreaTestCase)
Traceback (most recent call last):
  File "D:\GitHub\solutions geoprocessing toolbox\utils\test\incident_analysis_tests\HotSpotsByAreaTestCase.py", line 131, in test_hot_spots_by_area
    self.assertTrue(arcpy.Exists(outputFeatureClass))
AssertionError: False is not true
END OF TEST =========================================
'One or more tests failed'

Expected Behavior

Tests and tool should work with spaces in path names.

Current Behavior

See output log for test results: build.zip

Possible Solution

Steps to Reproduce (for bugs)

  1. Download/clone repo to local machine, say it goes into C:\GitHub\solutions-geoprocessing-toolbox
  2. Change the path to have spaces in it, for example: C:\GitHub\solutions geoprocessing toolbox
  3. Change directories to test folder: cd utils/test
  4. Run the Pro tests: TestKickPro.bat

Context

Jenkins tests are failing. Not sure if this is a problem in the tool or the tests.

Your Environment

@csmoore @ACueva

csmoore commented 7 years ago

The tests are failing - but this seems like a problem with the actual tools themselves:

Example - if I try to run the Geoname Gazetteer - it won't let me set the parameter if the folder has a space:

image

So we may have to skip these tests until these issues are resolved with the tools themselves

ACueva commented 7 years ago

I'll take a closer look to see if it's something I can fix.

adgiles commented 7 years ago

It's quite a well known issue that some of the geoprossing scripts are not forgiving with spaces in file paths:

https://gis.stackexchange.com/questions/24697/advantages-of-using-underscores-in-arcgis-file-naming-conventions

I personally wouldn't spend too much effort trying to fix that

ACueva commented 7 years ago

Ran the tool, verified the pathname in our Jenkins environment is causing this to fail. I was able to rename the project to Solutions_GP_Toolbox_Unit_tests_ArcMap and the new path is: c:\jenkins\Solutions_GP_Toolbox_Unit_tests_ArcMap\workspace

This makes it so the toolbox no longer throws an error.

I'm reverting the changes to the Jenkins Project name and I've unassigned this issue. Per @lfunkhouser we will address this issue during a future sprint.

kgonzago commented 7 years ago

@mfunk @ACueva Clarity is needed on why we're adding spaces to paths. Is that an intended test to determine if the tests are executed in a proper manner?

ACueva commented 7 years ago

I have a work-around for our Jenkins builds, aka, don't use a space in the project name. This might pop up again if a pipeline utilizes spaces in its name, or if we just forget. @mfunk thoughts on this?

kgonzago commented 7 years ago

It was agreed at scrum to add info in the README to NOT have any spaces in directory paths when executing the tests.

kgonzago commented 7 years ago

Changes are in this PR

mfunk commented 7 years ago

I'm not sure where the problem is as I'm able to manually run Create Geonames Gazetter Locator with a space in the path to the input features and output locator:

Executing: CreateGeonamesGazetteerLocator "'D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\Geonames.gdb\MonacoResults' 'Primary Table'" "D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\testoutput.gdb\outloc2"
Start Time: Mon Sep 18 07:11:09 2017
Executing (Create Address Locator): CreateAddressLocator "General - Gazetteer" "'D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\Geonames.gdb\MonacoResults' 'Primary Table'" "'Feature ID' ObjectID VISIBLE NONE;'*Place Name' PLACENAME VISIBLE NONE;Category FC VISIBLE NONE;Type DSG VISIBLE NONE;Tags <None> VISIBLE NONE;Description DSGNAME VISIBLE NONE;'3-Digit Language Code' LC VISIBLE NONE;'2-Digit Language Code' <None> VISIBLE NONE;Rank NAME_RANK VISIBLE NONE;Neighborhood <None> VISIBLE NONE;City <None> VISIBLE NONE;County <None> VISIBLE NONE;State ADM1NAME VISIBLE NONE;'State Abbreviation' ADM1CODE VISIBLE NONE;Country COUNTRYNAME1 VISIBLE NONE;'Country Abbreviation' COUNTRYCODE1 VISIBLE NONE;'Street Address' <None> VISIBLE NONE;'Full Address' <None> VISIBLE NONE;'Primary Phone' <None> VISIBLE NONE;'Primary URL' '' VISIBLE NONE;'Display X' POINT_X VISIBLE NONE;'Display Y' POINT_Y VISIBLE NONE;'Min X value for extent' POINT_X VISIBLE NONE;'Max X value for extent' POINT_X VISIBLE NONE;'Min Y value for extent' POINT_Y VISIBLE NONE;'Max Y value for extent' POINT_Y VISIBLE NONE;'Additional Field' USER_FLD VISIBLE NONE" "D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\testoutput.gdb\outloc2" # DISABLED
Start Time: Mon Sep 18 07:11:09 2017
Executing Create Address Locator...
Succeeded at Mon Sep 18 07:11:13 2017 (Elapsed Time: 4.32 seconds)
Succeeded at Mon Sep 18 07:11:14 2017 (Elapsed Time: 4.97 seconds)

But from the Python prompt in ArcMap:

>>> arcpy.CreateGeonamesGazetteerLocator_defensegeonames(r'D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\Geonames.gdb\MonacoResults', r'D:\GitHub\solutions geoprocessing toolbox\utils\test\test_data\geonames\testoutput.gdb\outloc5')
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\GitHub\solutions geoprocessing toolbox\geonames\Geonames Tools_arcmap.tbx", line 29, in CreateGeonamesGazetteerLocator
    RuntimeError: Object: Error in executing tool
>>> 

So the problem does NOT seem to be an issue in the tests, but how Python... or ArcPy is importing and using Create Geonames Gazetter Locator.

topowright-zz commented 6 years ago

This is a issue that should be closed based on the comments above. There should be no spaces in the path when doing unit test for gp.