Exemplo n.º 1
0
def test_gathered_dict_update():

    provider_test = Provider()
    members = (("foo3", "bar1"), ("foo2", "bar2"), ("foo1", "bar3"))
    memberdict = OrderedDict(members)
    gd = GatheredDict(provider_test)
    [gd.add_result(None, dict((member, ))) for member in members]
    # None results are ignored
    gd.add_result(None, None)
    newdict = dict()
    newdict.update(gd)
    assert all((k in newdict) for k in memberdict.keys())
    assert all((newdict[k] == v) for k, v in memberdict.items())
    assert len(newdict) == len(memberdict)
Exemplo n.º 2
0
def test_gathered_dict_update():

    provider_test = Provider()
    members = (
        ("foo3", "bar1"),
        ("foo2", "bar2"),
        ("foo1", "bar3"))
    memberdict = OrderedDict(members)
    gd = GatheredDict(provider_test)
    [gd.add_result(None, dict((member, )))
     for member in members]
    # None results are ignored
    gd.add_result(None, None)
    newdict = dict()
    newdict.update(gd)
    assert all((k in newdict) for k in memberdict.keys())
    assert all((newdict[k] == v) for k, v in memberdict.items())
    assert len(newdict) == len(memberdict)
Exemplo n.º 3
0
def test_gathered_dict():

    provider_test = Provider()

    with pytest.raises(TypeError):
        GatheredDict()

    members = (("foo3", "bar1"), ("foo2", "bar2"), ("foo1", "bar3"))
    memberdict = OrderedDict(members)
    gd = GatheredDict(provider_test)
    [gd.add_result(None, dict((member, ))) for member in members]
    assert gd.keys() == memberdict.keys()
    assert gd.values() == memberdict.values()
    assert gd.items() == memberdict.items()
    assert [x for x in gd] == memberdict.keys()
    assert all((k in gd) for k in memberdict.keys())
    assert all((gd.get(k) == gd[k]) for k in memberdict.keys())
    assert gd.get("DOES_NOT_EXIST") is None
    assert gd.get("DOES_NOT_EXIST", "DEFAULT") == "DEFAULT"
Exemplo n.º 4
0
def test_gathered_dict():

    provider_test = Provider()

    with pytest.raises(TypeError):
        GatheredDict()

    members = (
        ("foo3", "bar1"),
        ("foo2", "bar2"),
        ("foo1", "bar3"))
    memberdict = OrderedDict(members)
    gd = GatheredDict(provider_test)
    [gd.add_result(None, dict((member, )))
     for member in members]
    assert gd.keys() == memberdict.keys()
    assert gd.values() == memberdict.values()
    assert gd.items() == memberdict.items()
    assert [x for x in gd] == memberdict.keys()
    assert all((k in gd) for k in memberdict.keys())