Пример #1
0
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
Пример #2
0
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')
Пример #3
0
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
Пример #4
0
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')
Пример #5
0
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
Пример #6
0
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
Пример #7
0
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
Пример #8
0
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'
Пример #9
0
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
Пример #10
0
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'
Пример #11
0
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
Пример #12
0
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