Skip to content

Commit 1729f64

Browse files
committed
combine duplicate tests
1 parent 5c198d9 commit 1729f64

File tree

1 file changed

+25
-61
lines changed

1 file changed

+25
-61
lines changed

plotly/tests/test_core/test_plotly/test_plot.py

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,6 @@ class TestPlotOptionLogic(PlotlyTestCase):
223223
{'world_readable': True, 'sharing': 'private'},
224224
{'world_readable': False, 'sharing': 'public'}
225225
)
226-
opposite_option_set = (
227-
({'world_readable': True, 'sharing': 'public', 'auto_open': True},
228-
{'world_readable': False, 'sharing': 'secret', 'auto_open': False}),
229-
230-
({'world_readable': True, 'sharing': 'public', 'auto_open': False},
231-
{'world_readable': False, 'sharing': 'private', 'auto_open': True}),
232-
233-
({'world_readable': False, 'sharing': 'private', 'auto_open': True},
234-
{'world_readable': True, 'sharing': 'public', 'auto_open': False}),
235-
236-
({'world_readable': False, 'sharing': 'private', 'auto_open': False},
237-
{'world_readable': True, 'sharing': 'public', 'auto_open': True})
238-
)
239226

240227
def test_default_options(self):
241228
options = py._plot_option_logic({})
@@ -263,44 +250,6 @@ def test_set_config_updates_plot_options(self):
263250
self.assertEqual(new_options[key], options[key])
264251

265252

266-
def generate_call_signature_arguments_updates_options():
267-
def gen_test(config_plot_options, user_plot_options):
268-
tls.set_config_file(**config_plot_options)
269-
270-
def test(self):
271-
options = py._plot_option_logic(user_plot_options)
272-
273-
for key in user_plot_options:
274-
self.assertEqual(options[key], user_plot_options[key])
275-
self.assertNotEqual(options[key], config_plot_options[key])
276-
return test
277-
278-
for i, option_sets in enumerate(TestPlotOptionLogic.opposite_option_set):
279-
setattr(TestPlotOptionLogic,
280-
'test_call_signature_arguments_updates_options{}'.format(i),
281-
gen_test(option_sets[0], option_sets[1]))
282-
generate_call_signature_arguments_updates_options()
283-
284-
285-
def generate_call_signature_overrides_signin_and_config_file():
286-
def gen_test(signin_plot_options, user_plot_options):
287-
py.sign_in('username', 'key', **signin_plot_options)
288-
289-
def test(self):
290-
options = py._plot_option_logic(user_plot_options)
291-
292-
for key in user_plot_options:
293-
self.assertEqual(options[key], user_plot_options[key])
294-
self.assertNotEqual(options[key], signin_plot_options[key])
295-
return test
296-
297-
for i, option_sets in enumerate(TestPlotOptionLogic.opposite_option_set):
298-
setattr(TestPlotOptionLogic,
299-
'test_call_signature_overrides_signin_and_config_file{}'.format(i),
300-
gen_test(option_sets[0], option_sets[1]))
301-
generate_call_signature_overrides_signin_and_config_file()
302-
303-
304253
def generate_conflicting_plot_options_in_signin():
305254
"""sign_in overrides the default plot options.
306255
conflicting options aren't raised until plot or iplot is called,
@@ -370,22 +319,25 @@ def generate_private_sharing_and_public_world_readable_precedence():
370319
"""
371320
plot_option_sets = (
372321
{
373-
'parent': {'world_readable': True},
374-
'child': {'sharing': 'secret'},
322+
'parent': {'world_readable': True, 'auto_open': False},
323+
'child': {'sharing': 'secret', 'auto_open': True},
375324
'expected_output': {'world_readable': False,
376-
'sharing': 'secret'}
325+
'sharing': 'secret',
326+
'auto_open': True}
377327
},
378328
{
379-
'parent': {'world_readable': True},
380-
'child': {'sharing': 'private'},
329+
'parent': {'world_readable': True, 'auto_open': True},
330+
'child': {'sharing': 'private', 'auto_open': False},
381331
'expected_output': {'world_readable': False,
382-
'sharing': 'private'}
332+
'sharing': 'private',
333+
'auto_open': False}
383334
},
384335
{
385-
'parent': {'world_readable': False},
386-
'child': {'sharing': 'public'},
336+
'parent': {'world_readable': False, 'auto_open': False},
337+
'child': {'sharing': 'public', 'auto_open': True},
387338
'expected_output': {'world_readable': True,
388-
'sharing': 'public'}
339+
'sharing': 'public',
340+
'auto_open': True}
389341
}
390342
)
391343

@@ -397,10 +349,22 @@ def test(self):
397349
self.assertEqual(options[option], value)
398350
return test
399351

352+
def gen_test_config(plot_options):
353+
def test(self):
354+
tls.set_config(**plot_options['parent'])
355+
options = py._plot_option_logic(plot_options['child'])
356+
for option, value in plot_options['expected_output'].iteritems():
357+
self.assertEqual(options[option], value)
358+
400359
for i, plot_options in enumerate(plot_option_sets):
401360
setattr(TestPlotOptionLogic,
402361
'test_private_sharing_and_public_'
403-
'world_readable_precedence{}'.format(i),
362+
'world_readable_precedence_signin{}'.format(i),
404363
gen_test_signin(plot_options))
405364

365+
setattr(TestPlotOptionLogic,
366+
'test_private_sharing_and_public_'
367+
'world_readable_precedence_config{}'.format(i),
368+
gen_test_config(plot_options))
369+
406370
generate_private_sharing_and_public_world_readable_precedence()

0 commit comments

Comments
 (0)