示例#1
0
def test_driver_validation_error_handler(windows, instr_workbench):
    """Test the error handler dedicated to driver validation issues.

    """
    core = instr_workbench.get_plugin('enaml.workbench.core')
    p = instr_workbench.get_plugin('ecpy.instruments')
    d = DriverInfos(starter='starter',
                    connections={
                        'c1': {},
                        'c2': {}
                    },
                    settings={
                        's2': {},
                        's3': {}
                    })
    cmd = 'ecpy.app.errors.signal'

    def check_dialog(dial):
        w = dial.errors['ecpy.driver-validation']
        assert 'd' in w.errors
        for err in ('starter', 'connections', 'settings'):
            assert err in w.errors['d']

    with handle_dialog('accept', check_dialog):
        core.invoke_command(cmd, {
            'kind': 'ecpy.driver-validation',
            'details': {
                'd': d.validate(p)[1]
            }
        })
示例#2
0
def test_driver():
    """Test that the driver validation does work.

    """
    class FalsePlugin(object):
        """Lighter than using the real plugin.

        """
        pass
    p = FalsePlugin()
    p.starters = {'starter': None}
    p.connections = {'c1': {}, 'c2': {}, 'c3': {}}
    p.settings = {'s1': {}, 's2': {}, 's3': {}}

    # Test that when we know everything validation does work
    d = DriverInfos(starter='starter', connections={'c1': {}, 'c2': {}},
                    settings={'s2': {}, 's3': {}})
    assert d.validate(p)[0] and d.valid

    # Test validation failing because of starter
    p.starters.clear()
    assert not d.validate(p)[0] and not d.valid

    # Test validation failing because of one missing connection
    p.starters = {'starter': None}
    d.connections['c4'] = {}
    assert not d.validate(p)[0] and not d.valid

    # Test validation failing because of one missing settings
    del d.connections['c4']
    d.settings['s4'] = {}
    assert not d.validate(p)[0] and not d.valid
示例#3
0
def test_driver_validation_error_handler(windows, instr_workbench):
    """Test the error handler dedicated to driver validation issues.

    """
    core = instr_workbench.get_plugin("enaml.workbench.core")
    p = instr_workbench.get_plugin("ecpy.instruments")
    d = DriverInfos(starter="starter", connections={"c1": {}, "c2": {}}, settings={"s2": {}, "s3": {}})
    cmd = "ecpy.app.errors.signal"

    def check_dialog(dial):
        w = dial.errors["ecpy.driver-validation"]
        assert "d" in w.errors
        for err in ("starter", "connections", "settings"):
            assert err in w.errors[d]

    with handle_dialog("accept", check_dialog):
        core.invoke_command(cmd, {"kind": "ecpy.driver-validation", "details": {"d": d.validate(p)}})
        sleep(0.2)
示例#4
0
def test_driver_validation_error_handler(windows, instr_workbench):
    """Test the error handler dedicated to driver validation issues.

    """
    core = instr_workbench.get_plugin('enaml.workbench.core')
    p = instr_workbench.get_plugin('ecpy.instruments')
    d = DriverInfos(starter='starter', connections={'c1': {}, 'c2': {}},
                    settings={'s2': {}, 's3': {}})
    cmd = 'ecpy.app.errors.signal'

    def check_dialog(dial):
        w = dial.errors['ecpy.driver-validation']
        assert 'd' in w.errors
        for err in ('starter', 'connections', 'settings'):
            assert err in w.errors[d]

    with handle_dialog('accept', check_dialog):
        core.invoke_command(cmd, {'kind': 'ecpy.driver-validation',
                                  'details': {'d': d.validate(p)}})
示例#5
0
def test_driver():
    """Test that the driver validation does work.

    """
    class FalsePlugin(object):
        """Lighter than using the real plugin.

        """
        pass

    p = FalsePlugin()
    p.starters = {'starter': None}
    p.connections = {'c1': {}, 'c2': {}, 'c3': {}}
    p.settings = {'s1': {}, 's2': {}, 's3': {}}

    # Test that when we know everything validation does work
    d = DriverInfos(starter='starter',
                    connections={
                        'c1': {},
                        'c2': {}
                    },
                    settings={
                        's2': {},
                        's3': {}
                    })
    assert d.validate(p)[0] and d.valid

    # Test validation failing because of starter
    p.starters.clear()
    assert not d.validate(p)[0] and not d.valid

    # Test validation failing because of one missing connection
    p.starters = {'starter': None}
    d.connections['c4'] = {}
    assert not d.validate(p)[0] and not d.valid

    # Test validation failing because of one missing settings
    del d.connections['c4']
    d.settings['s4'] = {}
    assert not d.validate(p)[0] and not d.valid
示例#6
0
def create_driver_infos(id,
                        manufacturer='M',
                        serie='S',
                        model='m',
                        kind='Other',
                        architecture='a',
                        connections={'c1': {
                            'd': 1
                        }},
                        settings={'s1': {
                            's': 1
                        }}):
    return DriverInfos(id=id,
                       connections=connections,
                       settings=settings,
                       infos=dict(manufacturer=manufacturer,
                                  serie=serie,
                                  model=model,
                                  kind=kind,
                                  architecture=architecture))