From 66b6782659aa0275ac4c2bea0bfb5ab782aaf385 Mon Sep 17 00:00:00 2001 From: Isaac Virshup Date: Thu, 2 Aug 2018 11:26:41 +1000 Subject: [PATCH] Added tests for colorscales specified as a string Added tests checking that a colorscale specified as a string is returned correctly. Previously it had been returned as a tuple of 1-tuples. e.g. "Viridis" -> (('V',), ('i',), ('r',), ('i',), ('d',), ('i',), ('s',)). Catches #1087. --- .../tests/validators/test_colorscale_validator.py | 2 ++ .../test_graph_objs/test_properties_validated.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/_plotly_utils/tests/validators/test_colorscale_validator.py b/_plotly_utils/tests/validators/test_colorscale_validator.py index 74ffb41877..c179ff3958 100644 --- a/_plotly_utils/tests/validators/test_colorscale_validator.py +++ b/_plotly_utils/tests/validators/test_colorscale_validator.py @@ -26,6 +26,8 @@ def test_acceptance_named(named_colorscale, validator: ColorscaleValidator): # Uppercase assert (validator.validate_coerce(named_colorscale.upper()) == named_colorscale.upper()) + + assert validator.present(named_colorscale) == named_colorscale # ### Acceptance as array ### @pytest.mark.parametrize('val', [ diff --git a/plotly/tests/test_core/test_graph_objs/test_properties_validated.py b/plotly/tests/test_core/test_graph_objs/test_properties_validated.py index a7e25c9902..897b2104c7 100644 --- a/plotly/tests/test_core/test_graph_objs/test_properties_validated.py +++ b/plotly/tests/test_core/test_graph_objs/test_properties_validated.py @@ -102,6 +102,16 @@ def test_present_colorscale(self): # Presented as tuple of tuples self.assertEqual(self.scatter.marker.colorscale, ((0, 'red'), (1, 'green'))) + + def test_present_colorscale_str(self): + self.assertIsNone(self.scatter.marker.colorscale) + + # Assign string + self.scatter.marker.colorscale = "Viridis" + + # Presented as a string + self.assertEqual(self.scatter.marker.colorscale, + "Viridis") class TestPropertyIterContains(TestCase):