def test_instance_level_resolver(): from jupyter_sigplot.sigplot import Plot def to_foo(_): return 'foo' # If a single path resolver makes it all the way through the prepare step, # we assume that other tests ensure more complicated cases do, too. # Resolver specified in constructor p = Plot(path_resolvers=[to_foo]) p.overlay_href('baz') assert p.path_resolvers == [to_foo] assert p.command_and_arguments == { 'command': 'overlay_href', 'arguments': ['foo'] } # Resolver specified after construction p = Plot() p.path_resolvers = [to_foo] p.overlay_href('quux') assert p.path_resolvers == [to_foo] assert p.command_and_arguments == { 'command': 'overlay_href', 'arguments': ['foo'] }
def test_overlay_href(traitlet_set_mock): plot = Plot() plot.overlay_href('bar|baz') assert traitlet_set_mock.call_count == 2 for call_args in traitlet_set_mock.call_args_list: assert call_args[0][0]['command'] == 'overlay_href' assert len(call_args[0][0]['arguments']) == 1 assert call_args[0][0]['arguments'][0] in ('bar', 'baz')
def test_class_level_resolver(traitlet_set_mock): from jupyter_sigplot.sigplot import Plot def to_foo(_): return 'foo' Plot.path_resolvers = [to_foo] # Resolver applied post constructor p = Plot() p.overlay_href('baz|quux.mat') assert traitlet_set_mock.call_count == 2 for call_args in traitlet_set_mock.call_args_list: assert call_args[0][0]['command'] == 'overlay_href' assert len(call_args[0][0]['arguments']) == 1 assert call_args[0][0]['arguments'][0] == 'foo'