Skip to main content

Local / manual tests

Documentation mirror: This file matches tests/README.md in the swmm-feature-function repository; run the commands below from that repository root (tests/ paths refer to folders in the source tree).

Hybrid GeoJSON builders (unit/integration)​

Run schema and hybrid builder tests (requires pytest; optional rivershore.inp for builder tests):

pip install pytest
python -m pytest tests/test_geojson_hybrid.py -v

If rivershore.inp is not found (no sibling pyswmm/examples/rivershore.inp and no RIVERSHORE_INP_PATH), the builder tests are skipped. Schema tests always run.

Scene layers (3D SLPK)​

Place your .slpk (Scene Layer Package) file in this folder, then run:

python tests/test_publish_slpk.py --slpk tests/YourFile.slpk

Optional: --title "My Scene" and --folder SceneLayers to set the portal item title and folder.

If no --slpk is given, the script uses the first .slpk file found in this directory.

Feature layers (2D from INP)​

How "updating" existing layers works​

The publisher does not patch layers in place. To get new layers that include the dummy dynamic attributes (depth, head, flowRate, etc.) for an existing project:

  1. Via the HTTP trigger (recommended): Call publish-project-layers again with the same projectId. The function will:

    • Delete the project's existing feature layers (using item IDs from the ProjectFeatureMetaData table).
    • Publish new feature layers from the INP in blob storage (with the new schema including dummy attrs).
  2. Via the local script: Use the script below to publish from a local INP file. Each run creates new layers (titles include a timestamp). To replace old layers you would call delete-project-layers first (or delete the old items in ArcGIS), then run the script or the HTTP trigger.

Test the publish script locally (no Azure)​

Run the feature publisher with a local INP file. Requires ARCGIS_API_KEY (and optionally ARCGIS_URL) in the environment or in local.settings.json under Values:

python tests/test_publish_features.py --inp path/to/your/file.inp --project-id YourProjectId

Optional: --project-name "My Project", --folder "ArcGISFolderName", --title-prefix "SD1_".

Published layers will include the dummy dynamic attributes (e.g. depth, head, volume, flowRate, velocity, capacity = 0) so the schema matches the frontend.

Test via the function (full flow: blob + table + ArcGIS)​

  1. Set local.settings.json with Azure storage (connection string or account + SAS), PROJECT_TABLE_NAME, FEATURES_TABLE_NAME, and ARCGIS_API_KEY.

  2. Upload an INP to blob storage under swmm-input/{projectId}/ (e.g. swmm-input/MyProject/file.inp).

  3. Start the function: func start (from the repo root).

  4. Call the publish endpoint (use the function key if auth_level=FUNCTION):

    curl -X POST "http://localhost:7071/api/publish-project-layers" \
    -H "Content-Type: application/json" \
    -d "{\"projectId\": \"MyProject\"}"

    Optional body fields: blobPath, projectName.

  5. The function deletes existing feature layers for that project (from metadata), then publishes new layers from the INP. The new layers include the dummy dynamic attributes.