From 4f22e2b89607422306cd1a4377f8e761674750fb Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 21 Feb 2014 13:49:48 +0100 Subject: [PATCH] Fix combined tests --- pygal/test/__init__.py | 10 ++++++++-- pygal/test/test_config.py | 6 ++++-- pygal/test/test_graph.py | 17 +++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/pygal/test/__init__.py b/pygal/test/__init__.py index e0d7c6e..da94e4a 100644 --- a/pygal/test/__init__.py +++ b/pygal/test/__init__.py @@ -21,7 +21,7 @@ import pygal 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): @@ -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 diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index bf0f29c..deb0e22 100644 --- a/pygal/test/test_config.py +++ b/pygal/test/test_config.py @@ -18,7 +18,8 @@ # along with pygal. If not, see . 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 @@ -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 diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index 9ba8da0..5b87285 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -21,6 +21,7 @@ import pygal 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 @@ -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], @@ -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')) @@ -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: