Test to make sure that Choropleth function doesn't allow values outside of the domain defined by bins. It also tests that all parameters work as expected regarding nan and missing values.
(self)
| 191 | assert "".join(topojson_str.split())[:-1] in "".join(out.split()) |
| 192 | |
| 193 | def test_choropleth_features(self): |
| 194 | """Test to make sure that Choropleth function doesn't allow |
| 195 | values outside of the domain defined by bins. |
| 196 | |
| 197 | It also tests that all parameters work as expected regarding |
| 198 | nan and missing values. |
| 199 | """ |
| 200 | with open(os.path.join(rootpath, "us-counties.json")) as f: |
| 201 | geo_data = json.load(f) |
| 202 | data = {"1001": -1} |
| 203 | fill_color = "BuPu" |
| 204 | key_on = "id" |
| 205 | |
| 206 | with pytest.raises(ValueError): |
| 207 | Choropleth( |
| 208 | geo_data=geo_data, |
| 209 | data=data, |
| 210 | key_on=key_on, |
| 211 | fill_color=fill_color, |
| 212 | bins=[0, 1, 2, 3], |
| 213 | ).add_to(self.m) |
| 214 | self.m._parent.render() |
| 215 | |
| 216 | Choropleth( |
| 217 | geo_data=geo_data, |
| 218 | data={"1001": 1, "1003": float("nan")}, |
| 219 | key_on=key_on, |
| 220 | fill_color=fill_color, |
| 221 | fill_opacity=0.543212345, |
| 222 | nan_fill_color="a_random_color", |
| 223 | nan_fill_opacity=0.123454321, |
| 224 | ).add_to(self.m) |
| 225 | |
| 226 | out = self.m._parent.render() |
| 227 | out_str = "".join(out.split()) |
| 228 | assert '"fillColor":"a_random_color","fillOpacity":0.123454321' in out_str |
| 229 | assert '"fillOpacity":0.543212345' in out_str |
| 230 | |
| 231 | def test_choropleth_key_on(self): |
| 232 | """Test to make sure that Choropleth function doesn't raises |
nothing calls this directly
no test coverage detected