Tests `self.style_function` and `self.highlight_function` to ensure they are functions returning dictionaries.
(self, func: Callable, name: str)
| 800 | self.data = {"type": "FeatureCollection", "features": [self.data]} |
| 801 | |
| 802 | def _validate_function(self, func: Callable, name: str) -> None: |
| 803 | """ |
| 804 | Tests `self.style_function` and `self.highlight_function` to ensure |
| 805 | they are functions returning dictionaries. |
| 806 | """ |
| 807 | # If for some reason there are no features (e.g., empty API response) |
| 808 | # don't attempt validation |
| 809 | if not self.data["features"]: |
| 810 | return |
| 811 | |
| 812 | test_feature = self.data["features"][0] |
| 813 | if not callable(func) or not isinstance(func(test_feature), dict): |
| 814 | raise ValueError( |
| 815 | f"{name} should be a function that accepts items from " |
| 816 | "data['features'] and returns a dictionary." |
| 817 | ) |
| 818 | |
| 819 | def find_identifier(self) -> str: |
| 820 | """Find a unique identifier for each feature, create it if needed. |