Skip to content

Popup tests #254

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 1 commit into from
Jan 15, 2016
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
3 changes: 3 additions & 0 deletions folium/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

Classes for drawing maps.
"""

from __future__ import unicode_literals
Copy link
Contributor

Choose a reason for hiding this comment

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

@ocefpaf
Just for curiosity: what is it for ?

Copy link
Member Author

Choose a reason for hiding this comment

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

So we can use "Ça c'est chouette" instead of u"Ça c'est chouette". Embrace the future 😉


import warnings
import json
from collections import OrderedDict
Expand Down
47 changes: 47 additions & 0 deletions tests/test_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-

"""
Folium map Tests
----------------

"""
from __future__ import unicode_literals

from folium.map import Popup # TODO: Map, Marker, ...
Copy link
Member Author

Choose a reason for hiding this comment

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

I want to add tests for everything in the folium.map namespace.



tmpl = """
<div id="{id}"
style="width: {width}; height: {height};">
{text}</div>
""".format


def test_popup_ascii():
popup = Popup('Some text.')
_id = list(popup.html._children.keys())[0]
kw = dict(id=_id,
width='100.0%',
height='100.0%',
text='Some text.')
assert popup.html.render().strip() == tmpl(**kw).strip()


def test_popup_quotes():
popup = Popup("Let's try quotes")
_id = list(popup.html._children.keys())[0]
kw = dict(id=_id,
width='100.0%',
height='100.0%',
text='Let&#39;s try quotes')
assert popup.html.render().strip() == tmpl(**kw).strip()


def test_popup_unicode():
popup = Popup("Ça c'est chouette")
_id = list(popup.html._children.keys())[0]
kw = dict(id=_id,
width='100.0%',
height='100.0%',
text="Ça c&#39;est chouette")
assert popup.html.render().strip() == tmpl(**kw).strip()