Skip to content

Add cached-data test mode by monkeypatching OSMnx network boundary in map_utils #272

@paco-barreras

Description

@paco-barreras

After generating cached data from OSM, , add a cached-data mode for tests where map_utils runs normally but OSM network calls are replaced with local cached data.

In pytest, monkeypatch temporarily replaces a function for the duration of a test and then restores it. Here, that means we keep running your methods (download_osm_buildings, download_osm_streets, get_city_boundary_osm) exactly as written, but we replace only the external OSMnx calls they use.

We should patch these nomad.map_utils.ox.* functions in cached-mode tests:

  • nomad.map_utils.ox.features_from_bbox
  • nomad.map_utils.ox.features_from_polygon
  • nomad.map_utils.ox.geocode_to_gdf
  • nomad.map_utils.ox.graph_from_bbox
  • nomad.map_utils.ox.graph_from_polygon
     
    Cached-mode versions of the tests that currently depend on live data in nomad/tests/test_maps.py, specifically around:
  • test_download_osm_buildings_*
  • test_download_osm_streets*
  • test_city_boundary_by_name_*

If cached files are missing, cached-mode tests should fail with a clear message: run the cache script first. This is expected short term. We should add a warning in docs that large geospatial artifacts can bloat repository history quickly.
 

Acceptance

 

  • Cached-mode tests run without network.
  • Missing cache produces a clear, intentional failure message

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions