Skip to content

Commit

Permalink
Fix combined tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Feb 21, 2014
1 parent 8a5586e commit 4f22e2b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
10 changes: 8 additions & 2 deletions pygal/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pygal.util import cut
from datetime import datetime
from pygal.i18n import COUNTRIES
COUNTRY_KEYS = list(COUNTRIES.keys())
from pygal.graph.frenchmap import DEPARTMENTS, REGIONS


def get_data(i):
Expand Down Expand Up @@ -58,8 +58,14 @@ def adapt(chart, data):

data = cut(data)
if isinstance(chart, pygal.Worldmap):
return list(map(lambda x: COUNTRY_KEYS[x % len(COUNTRIES)]
return list(map(lambda x: list(COUNTRIES.keys())[x % len(COUNTRIES)]
if x is not None else None, data))
elif isinstance(chart, pygal.FrenchMap_Regions):
return list(map(lambda x: list(REGIONS.keys())[x % len(REGIONS)]
if x is not None else None, data))
elif isinstance(chart, pygal.FrenchMap_Departments):
return list(map(lambda x: list(DEPARTMENTS.keys())[x % len(DEPARTMENTS)]
if x is not None else None, data))
return data


Expand Down
6 changes: 4 additions & 2 deletions pygal/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
from pygal import (
Line, Dot, Pie, Radar, Config, Bar, Funnel, Worldmap,
SupranationalWorldmap, Histogram, Gauge, Box)
SupranationalWorldmap, Histogram, Gauge, Box,
FrenchMap_Regions, FrenchMap_Departments)
from pygal._compat import u
from pygal.test.utils import texts
from pygal.test import pytest_generate_tests, make_data
Expand Down Expand Up @@ -270,7 +271,8 @@ def test_no_data():
def test_include_x_axis(Chart):
chart = Chart()
if Chart in (Pie, Radar, Funnel, Dot, Gauge, Worldmap,
SupranationalWorldmap, Histogram, Box):
SupranationalWorldmap, Histogram, Box,
FrenchMap_Regions, FrenchMap_Departments):
return
if not chart.cls._dual:
data = 100, 200, 150
Expand Down
17 changes: 13 additions & 4 deletions pygal/test/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uuid
import sys
from pygal import i18n
from pygal.graph.frenchmap import DEPARTMENTS, REGIONS
from pygal.util import cut
from pygal._compat import u
from pygal.test import pytest_generate_tests, make_data
Expand Down Expand Up @@ -73,7 +74,11 @@ def test_metadata(Chart):
elif Chart == pygal.XY:
v = list(map(lambda x: (x, x + 1), v))
elif Chart == pygal.Worldmap or Chart == pygal.SupranationalWorldmap:
v = list(map(lambda x: x, i18n.COUNTRIES))
v = [(i, k) for k, i in enumerate(i18n.COUNTRIES.keys())]
elif Chart == pygal.FrenchMap_Regions:
v = [(i, k) for k, i in enumerate(REGIONS.keys())]
elif Chart == pygal.FrenchMap_Departments:
v = [(i, k) for k, i in enumerate(DEPARTMENTS.keys())]

chart.add('Serie with metadata', [
v[0],
Expand All @@ -96,8 +101,10 @@ def test_metadata(Chart):
if Chart == pygal.Pie:
# Slices with value 0 are not rendered
assert len(v) - 1 == len(q('.tooltip-trigger').siblings('.value'))
elif Chart != pygal.Worldmap and Chart != pygal.SupranationalWorldmap:
# Tooltip are not working on worldmap
elif Chart not in (
pygal.Worldmap, pygal.SupranationalWorldmap,
pygal.FrenchMap_Regions, pygal.FrenchMap_Departments):
# Tooltip are not working on maps
assert len(v) == len(q('.tooltip-trigger').siblings('.value'))


Expand Down Expand Up @@ -335,7 +342,9 @@ def test_labels_with_links(Chart):
q = chart.render_pyquery()
links = q('a')

if issubclass(chart.cls, pygal.graph.worldmap.Worldmap):
if issubclass(chart.cls,
(pygal.graph.worldmap.Worldmap,
pygal.graph.frenchmap.FrenchMapDepartments)):
# No country is found in this case so:
assert len(links) == 4 # 3 links and 1 tooltip
else:
Expand Down

0 comments on commit 4f22e2b

Please sign in to comment.