Пример #1
0
def test_profile_clone(false_plugin_with_holder):
    """Test cloning a profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)

    p.id = 'new'
    p2 = p.clone()
    assert p2.id == 'new'
    assert p2.model.model == 'model'
Пример #2
0
def test_profile_clone(false_plugin_with_holder):
    """Test cloning a profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)

    p.id = 'new'
    p2 = p.clone()
    assert p2.id == 'new'
    assert p2.model.model == 'model'
Пример #3
0
def test_profile_members(false_plugin_with_holder):
    """Test accessing the values stored in the profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)
    assert p.id == 'profile'
    assert p.model.model == 'model'
    assert sorted(p.connections) == ['visa_tcpip', 'visa_usb']
    assert sorted(p.settings) == ['lantz', 'lantz-sim']

    p._config = {'id': 'new'}
    assert p.id == 'new'
Пример #4
0
def test_profile_members(false_plugin_with_holder):
    """Test accessing the values stored in the profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)
    assert p.id == 'profile'
    assert p.model.model == 'model'
    assert sorted(p.connections) == ['visa_tcpip', 'visa_usb']
    assert sorted(p.settings) == ['lantz', 'lantz-sim']

    p._config = {'id': 'new'}
    assert p.id == 'new'
Пример #5
0
def test_profile_blank(false_plugin_with_holder):
    """Test creating a blank profile.

    """
    p = ProfileInfos.create_blank(false_plugin_with_holder)
    assert not p.id
    assert not p.connections
    assert not p.settings
    assert p._config
Пример #6
0
def test_validate_profile_infos(tmpdir, false_plugin_with_holder):
    """Test validating a profile.

    """
    i = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)
    r, msg = validate_profile_infos(i)
    assert r

    for p, m in [(os.path.join(str(tmpdir), 'd_%s.instr.ini' % m), m)
                 for m in ('id', 'model_id', 'connections', 'settings')]:
        c = ConfigObj(PROFILE_PATH)
        del c[m]
        with open(p, 'wb') as f:
            c.write(f)
        i = ProfileInfos(path=p, plugin=false_plugin_with_holder)
        r, msg = validate_profile_infos(i)
        assert not r
        assert m in msg
Пример #7
0
def test_profile_blank(false_plugin_with_holder):
    """Test creating a blank profile.

    """
    p = ProfileInfos.create_blank(false_plugin_with_holder)
    assert not p.id
    assert not p.connections
    assert not p.settings
    assert p._config
Пример #8
0
def test_profile_write(tmpdir, false_plugin_with_holder):
    """Test writing a modified profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)
    p.id = 'new'
    p.model.serie = 'S'
    p.model.model = 'm2'
    p.connections['new'] = {'inf': 1}
    p.settings['new'] = {'inf': 2}
    path = str(tmpdir.join('new.ini'))
    p.path = path
    p.write_to_file()

    p = ProfileInfos(path=path, plugin=false_plugin_with_holder)
    assert p.id == 'new'
    assert p.model.model == 'm2'
    assert 'new' in p.connections and 'visa_tcpip' in p.connections
    assert 'new' in p.settings and 'lantz' in p.settings
Пример #9
0
def test_profile_write(tmpdir, false_plugin_with_holder):
    """Test writing a modified profile.

    """
    p = ProfileInfos(path=PROFILE_PATH, plugin=false_plugin_with_holder)
    p.id = 'new'
    p.model.serie = 'S'
    p.model.model = 'm2'
    p.connections['new'] = {'inf': 1}
    p.settings['new'] = {'inf': 2}
    path = str(tmpdir.join('new.ini'))
    p.path = path
    p.write_to_file()

    p = ProfileInfos(path=path, plugin=false_plugin_with_holder)
    assert p.id == 'new'
    assert p.model.model == 'm2'
    assert 'new' in p.connections and 'visa_tcpip' in p.connections
    assert 'new' in p.settings and 'lantz' in p.settings