Test class for the Folium library.
| 54 | |
| 55 | |
| 56 | class TestFolium: |
| 57 | """Test class for the Folium library.""" |
| 58 | |
| 59 | def setup_method(self): |
| 60 | """Setup Folium Map.""" |
| 61 | attr = "http://openstreetmap.org" |
| 62 | self.m = folium.Map( |
| 63 | location=[45.5236, -122.6750], |
| 64 | width=900, |
| 65 | height=400, |
| 66 | max_zoom=20, |
| 67 | zoom_start=4, |
| 68 | max_bounds=True, |
| 69 | font_size="1.5rem", |
| 70 | attr=attr, |
| 71 | ) |
| 72 | self.fit_bounds_template = Template( |
| 73 | """ |
| 74 | {% if autobounds %} |
| 75 | var autobounds = L.featureGroup({{ features }}).getBounds() |
| 76 | {% if not bounds %} |
| 77 | {% set bounds = "autobounds" %} |
| 78 | {% endif %} |
| 79 | {% endif %} |
| 80 | {% if bounds %} |
| 81 | {{this._parent.get_name()}}.fitBounds({{ bounds }}, |
| 82 | {{ fit_bounds_options }} |
| 83 | ); |
| 84 | {% endif %} |
| 85 | """ |
| 86 | ) |
| 87 | |
| 88 | def test_init(self): |
| 89 | """Test map initialization.""" |
| 90 | |
| 91 | assert self.m.get_name().startswith("map_") |
| 92 | assert self.m.get_root() == self.m._parent |
| 93 | assert self.m.location == [45.5236, -122.6750] |
| 94 | assert self.m.options["zoom"] == 4 |
| 95 | assert self.m.options["max_bounds"] == [[-90, -180], [90, 180]] |
| 96 | assert self.m.position == "relative" |
| 97 | assert self.m.height == (400, "px") |
| 98 | assert self.m.width == (900, "px") |
| 99 | assert self.m.left == (0, "%") |
| 100 | assert self.m.top == (0, "%") |
| 101 | assert self.m.global_switches.no_touch is False |
| 102 | assert self.m.global_switches.disable_3d is False |
| 103 | assert self.m.font_size == "1.5rem" |
| 104 | assert self.m.to_dict() == { |
| 105 | "name": "Map", |
| 106 | "id": self.m._id, |
| 107 | "children": { |
| 108 | "openstreetmap": { |
| 109 | "name": "TileLayer", |
| 110 | "id": self.m._children["openstreetmap"]._id, |
| 111 | "children": {}, |
| 112 | } |
| 113 | }, |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…