def text_monitor_plugin(text_monitor_workbench): """Create a text monitor with some interesting preferences. """ conf = {} path = 'exopy.measurement.monitors.text_monitor' rule1 = { 'class_id': 'exopy.FormatRule', 'id': 'test_format', 'suffixes': repr(['a', 'b']), 'new_entry_formatting': '{a}/{b}', 'new_entry_suffix': 'c' } rule2 = { 'class_id': 'exopy.RejectRule', 'id': 'test_reject', 'suffixes': repr(['a', 'b']) } conf[path] = { '_user_rules': repr({ 'test_format': rule1, 'test_reject': rule2 }), 'default_rules': repr(['test_format', 'unknown']) } set_preferences(text_monitor_workbench, conf) p = text_monitor_workbench.get_plugin( 'exopy.measurement.monitors.text_monitor') # Set manually as we added those without the preferences. p.default_rules = ['test_format', 'unknown'] return p
def test_handling_not_found_default_tools(measurement_workbench): """Test handling the non-dectection of default tools. """ set_preferences(measurement_workbench, {'exopy.measurement': {'default_monitors': "['dummy']"}}) with pytest.raises(ErrorDialogException): measurement_workbench.get_plugin('exopy.measurement')
def test_starting_with_default_tools(measurement_workbench): """Test staring with default selected tools. """ measurement_workbench.register(MeasureTestManifest()) set_preferences(measurement_workbench, {'exopy.measurement': {'default_monitors': "['dummy']"}}) plugin = measurement_workbench.get_plugin('exopy.measurement') assert plugin.default_monitors
def test_handling_not_found_default_tools(measurement_workbench): """Test handling the non-dectection of default tools. """ set_preferences(measurement_workbench, {'exopy.measurement': { 'default_monitors': "['dummy']" }}) with pytest.raises(ErrorDialogException): measurement_workbench.get_plugin('exopy.measurement')
def test_handling_missing_default_rule(text_monitor_workbench, caplog): """Test that default rules not backed by a config are discarded. """ conf = {} path = 'exopy.measurement.monitors.text_monitor' conf[path] = {'default_rules': repr(['test_format', 'unknown'])} set_preferences(text_monitor_workbench, conf) text_monitor_workbench.get_plugin( 'exopy.measurement.monitors.text_monitor') assert caplog.records
def test_starting_with_default_tools(measurement_workbench): """Test staring with default selected tools. """ measurement_workbench.register(MeasureTestManifest()) set_preferences(measurement_workbench, {'exopy.measurement': { 'default_monitors': "['dummy']" }}) plugin = measurement_workbench.get_plugin('exopy.measurement') assert plugin.default_monitors
def test_overriding_preferences_if_absent(icon_workbench): """Test that we fall back to FontAwesome is the selected theme in the preferences does not exist. """ set_preferences(icon_workbench, {'exopy.app.icons': {'current_theme': '_d_', 'fallback_theme': '_f'} } ) pl = icon_workbench.get_plugin('exopy.app.icons') assert pl.current_theme == pl.icon_themes[0] assert pl.fallback_theme == 'exopy.FontAwesome'
def test_starting_with_a_default_selected_engine(measurement_workbench): """Test that an engine selected by default is well mounted. """ measurement_workbench.register(MeasureTestManifest()) set_preferences(measurement_workbench, {'exopy.measurement': {'selected_engine': 'dummy'}}) plugin = measurement_workbench.get_plugin('exopy.measurement') decl = plugin.get_declarations('engine', ['dummy'])['dummy'] assert plugin.selected_engine == 'dummy' assert decl.selected
def test_overriding_preferences_if_absent(icon_workbench): """Test that we fall back to FontAwesome is the selected theme in the preferences does not exist. """ set_preferences( icon_workbench, {'exopy.app.icons': { 'current_theme': '_d_', 'fallback_theme': '_f' }}) pl = icon_workbench.get_plugin('exopy.app.icons') assert pl.current_theme == pl.icon_themes[0] assert pl.fallback_theme == 'exopy.FontAwesome'
def test_starting_with_a_default_selected_engine(measurement_workbench): """Test that an engine selected by default is well mounted. """ measurement_workbench.register(MeasureTestManifest()) set_preferences(measurement_workbench, {'exopy.measurement': { 'selected_engine': 'dummy' }}) plugin = measurement_workbench.get_plugin('exopy.measurement') decl = plugin.get_declarations('engine', ['dummy'])['dummy'] assert plugin.selected_engine == 'dummy' assert decl.selected
def text_monitor_plugin(text_monitor_workbench): """Create a text monitor with some interesting preferences. """ conf = {} path = 'exopy.measurement.monitors.text_monitor' rule1 = {'class_id': 'exopy.FormatRule', 'id': 'test_format', 'suffixes': repr(['a', 'b']), 'new_entry_formatting': '{a}/{b}', 'new_entry_suffix': 'c'} rule2 = {'class_id': 'exopy.RejectRule', 'id': 'test_reject', 'suffixes': repr(['a', 'b'])} conf[path] = {'_user_rules': repr({'test_format': rule1, 'test_reject': rule2}), 'default_rules': repr(['test_format', 'unknown'])} set_preferences(text_monitor_workbench, conf) p = text_monitor_workbench.get_plugin( 'exopy.measurement.monitors.text_monitor') # Set manually as we added those without the preferences. p.default_rules = ['test_format', 'unknown'] return p