From a1acaacf0e0b051a91a18d28e4c7735b502f8097 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 13 Feb 2015 17:58:03 +0100 Subject: [PATCH] Add tests that fails referencing #188 --- demo/moulinrouge/tests.py | 7 +++++++ pygal/test/test_graph.py | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 83d63a3..5149d20 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -8,6 +8,7 @@ from pygal.style import styles, Style, RotateStyle from pygal.colors import rotate from pygal.graph.frenchmap import DEPARTMENTS, REGIONS from random import randint, choice +from datetime import datetime def get_test_routes(app): @@ -218,6 +219,12 @@ def get_test_routes(app): graph.title = '123456789 ' * 30 return graph.render_response() + @app.route('/test/datey_single') + def test_datey_single(): + graph = DateY(interpolate='cubic') + graph.add('Single', [(datetime.now(), 1)]) + return graph.render_response() + @app.route('/test/no_data/at_all/') def test_no_data_at_all_for(chart): graph = CHARTS_BY_NAME[chart]() diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index 15fec48..1d223ee 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -132,6 +132,31 @@ def test_empty_lists_with_nones(Chart): q = chart.render_pyquery() assert len(q(".legend")) == 2 + +def test_only_one_value(Chart): + chart = Chart() + chart.add('S', [1]) + chart.x_labels = ('single') + q = chart.render_pyquery() + assert len(q(".legend")) == 1 + + +def test_only_one_value_log(Chart): + chart = Chart(logarithmic=True) + chart.add('S', [1]) + chart.x_labels = ('single') + q = chart.render_pyquery() + assert len(q(".legend")) == 1 + + +def test_only_one_value_intrp(Chart): + chart = Chart(interpolate='cubic') + chart.add('S', [1]) + chart.x_labels = ('single') + q = chart.render_pyquery() + assert len(q(".legend")) == 1 + + def test_non_iterable_value(Chart): chart = Chart(no_prefix=True) chart.add('A', 1)