Skip to content

tests(#2406): add test_osm.py#2604

Open
bruno-portfolio wants to merge 2 commits intogee-community:masterfrom
bruno-portfolio:tests-osm
Open

tests(#2406): add test_osm.py#2604
bruno-portfolio wants to merge 2 commits intogee-community:masterfrom
bruno-portfolio:tests-osm

Conversation

@bruno-portfolio
Copy link
Copy Markdown
Contributor

Summary

Adds unit test coverage for the osm module as requested in #2406.

Follows up on @schwehr's suggestion in #2575.

Changes

  • 35 tests in a single OsmTest class
  • Covers all public functions: address, place, point, polygon, bbox, xml, geocode, tags_list
  • Uses sys.modules mock for osmnx (no network calls)
  • Inline mock GeoDataFrame with __geo_interface__
  • No external mock files needed
  • All assertions verify exact call arguments or return values

Comment thread tests/test_osm.py Outdated
def setUp(self):
mock_ox.reset_mock()

# ------------------------------------------------------------------ #
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these separator comments here and below

Comment thread tests/test_osm.py
import unittest
from unittest import mock

mock_ox = mock.MagicMock()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment explaining why this is needed.

Comment thread tests/test_osm.py Outdated
# osm_shp_from_address
# ------------------------------------------------------------------ #

@mock.patch("geemap.osm.osm_gdf_from_address")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use mock.patch.object when possible here and below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants