Пример #1
0
def test_BSConfig_for_apiurl():
    
    global CFG_DICT
    cfg = BSConfig(**CFG_DICT)

    with pytest.raises(ValueError):
        ocfg = cfg.for_apiurl("https://api.opensuse.org")
    
    ocfg = cfg.for_apiurl("https://api.opensuse.org/")
    assert cfg != ocfg
    assert cfg.items() != ocfg.items()
    assert set(ocfg.items()) == \
        {('pswd', "joes's passwd"), ('apiurl', 'https://api.opensuse.org/'), ('pass', 'bar'), ('passx', 'ham'), ('user', 'joe')}
    
    icfg = cfg.for_apiurl("https://api.suse.de")
    assert cfg != icfg
    assert ocfg != icfg
    assert ocfg.items() != icfg.items()
    assert icfg.apiurl == "https://api.suse.de"
Пример #2
0
def test_BSConfig_basic():
    foo = BSConfig(a=11)
    assert foo.a == 11
    assert hasattr(foo, "a")
    assert getattr(foo, "a") == 11
    assert foo["a"] == 11
    assert len(foo) == 1
    assert "a" in foo

    for k, v in foo.items():
        assert k == "a"
        assert v == 11

    for v in foo.values():
        assert v == 11

    for k in foo.keys():
        assert k == "a"

    assert type(foo.__iter__()) == type({}.__iter__())