Skip to content

tests(#2406): add test_deck.py#2580

Merged
schwehr merged 3 commits into
gee-community:masterfrom
bruno-portfolio:tests-deck
Feb 5, 2026
Merged

tests(#2406): add test_deck.py#2580
schwehr merged 3 commits into
gee-community:masterfrom
bruno-portfolio:tests-deck

Conversation

@bruno-portfolio
Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for the deck module as requested in #2406.

Changes

  • 19 tests covering Map initialization, layers, and method availability
  • Uses ee_initialize=False to avoid Earth Engine dependency
  • Single test class following project conventions

Verification

python -m unittest discover -v tests test_deck.py

All 19 tests pass locally.


Continuation of #2575, following the incremental PR approach as by @schwehr.

@schwehr schwehr self-assigned this Feb 4, 2026
schwehr added a commit to schwehr/geemap that referenced this pull request Feb 5, 2026
Comment thread tests/test_deck.py Outdated
m.add_layer("https://example.com/tiles2/{z}/{x}/{y}.png", layer_name="layer2")
self.assertEqual(len(m.layers), 2)

def test_layer_class_exists(self):
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.

I don't think these hasattr and issubclass are providing useful test coverage. Why are they needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, they're not needed, the other tests already exercise those classes and methods. I'll remove them.

Comment thread tests/test_deck.py Outdated
self.assertIsNotNone(m)
self.assertEqual(m.initial_view_state.height, 600)

def test_map_default_center(self):
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.

Please combine all the tests that only have this one line into test_map_init_default_params:

m = deck.Map(ee_initialize=False)

That looks to be test_map_default_center, test_map_default_zoom, test_map_default_height, test_map_default_map_style, test_map_layers_initially_empty

Copy link
Copy Markdown
Collaborator

@schwehr schwehr left a comment

Choose a reason for hiding this comment

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

For future changes, please just do additional commits on top of what is reviewed. That way the changes are more obvious to the reviewer. I will do a squash and merge at the end so extra commits will not appear in the final history.

I think after this one last change, the PR should be good to go.

Thank you!

Comment thread tests/test_deck.py Outdated

def test_map_init_custom_center(self):
m = deck.Map(ee_initialize=False, center=(40, -100))
self.assertIsNotNone(m)
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 the self.assertIsNotNone(m) from here to the end. If for some odd reason deck.Map(...) returns None, the first access of m. will catch that. It will be a slightly messier error message, but that will keep the test code easier to follow as it grows.

@schwehr schwehr merged commit 0824525 into gee-community:master Feb 5, 2026
13 checks passed
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