Browse Source

Fix combined tests

pull/98/head
Florian Mounier 11 years ago
parent
commit
4f22e2b896
  1. 10
      pygal/test/__init__.py
  2. 6
      pygal/test/test_config.py
  3. 17
      pygal/test/test_graph.py

10
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,7 +58,13 @@ 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

6
pygal/test/test_config.py

@ -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
@ -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

17
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:

Loading…
Cancel
Save