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'
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'
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
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
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