def test_BSConfig_fromoscrc(oscrc): cfg = BSConfig.fromoscrc(path=oscrc) assert 'general' in cfg for apiurl in cfg.apiurls(): assert cfg[apiurl].user == "joe" assert cfg[apiurl].pswd == "doe"
def test_BSConfig_badoscrc(oscrc_nouser): with pytest.raises(ValueError): cfg = BSConfig(**{"https://api.foo.net/" : {"bar" : 42}}) with pytest.raises(ValueError): cfg = BSConfig.fromoscrc(path=oscrc_nouser)
def test_BSConfig_badperms(oscrc_badperm): with pytest.raises(Exception): cfg = BSConfig.fromoscrc(path=oscrc_badperm)
def fromoscrc(cls, apiurl, path=None): """Load context from oscrc and setup the logger properly""" from bslib.config import BSConfig #TODO: logger handling return cls(config=BSConfig.fromoscrc(path).for_apiurl(apiurl), logger=None)