Skip to content

cleanup fit_bounds.js template from tests #1920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions folium/templates/fit_bounds.js

This file was deleted.

24 changes: 18 additions & 6 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pandas as pd
import pytest
import xyzservices.providers as xyz
from jinja2 import Environment, PackageLoader
from jinja2 import Template
from jinja2.utils import htmlsafe_json_dumps

import folium
Expand Down Expand Up @@ -78,7 +78,21 @@ def setup_method(self):
font_size="1.5rem",
attr=attr,
)
self.env = Environment(loader=PackageLoader("folium", "templates"))
self.fit_bounds_template = Template(
"""
{% if autobounds %}
var autobounds = L.featureGroup({{ features }}).getBounds()
{% if not bounds %}
{% set bounds = "autobounds" %}
{% endif %}
{% endif %}
{% if bounds %}
{{this._parent.get_name()}}.fitBounds({{ bounds }},
{{ fit_bounds_options }}
);
{% endif %}
"""
)

def test_init(self):
"""Test map initialization."""
Expand Down Expand Up @@ -394,8 +408,7 @@ def test_fit_bounds(self):
][0]
out = self.m._parent.render()

fit_bounds_tpl = self.env.get_template("fit_bounds.js")
fit_bounds_rendered = fit_bounds_tpl.render(
fit_bounds_rendered = self.fit_bounds_template.render(
{
"bounds": json.dumps(bounds),
"this": fitbounds,
Expand All @@ -415,8 +428,7 @@ def test_fit_bounds_2(self):
][0]
out = self.m._parent.render()

fit_bounds_tpl = self.env.get_template("fit_bounds.js")
fit_bounds_rendered = fit_bounds_tpl.render(
fit_bounds_rendered = self.fit_bounds_template.render(
{
"bounds": json.dumps(bounds),
"fit_bounds_options": json.dumps(
Expand Down