Ejemplo n.º 1
0
def test_rrd_unmap_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r["foo"] == 2
    assert r.original == {1: 2}
    r.unmap()
    assert r.original == {1: 2}
Ejemplo n.º 2
0
def test_rrd_unmap():
    r = RRD({1: 2})
    assert r[1] == 2
    r.remap({1: "foo"})
    assert r["foo"] == 2
    with pytest.raises(KeyError):
        r[1]
    r.unmap()
    assert r[1] == 2
    with pytest.raises(KeyError):
        r["foo"]
Ejemplo n.º 3
0
def test_rrd_unmap_reversed():
    r = RRD({1: 2})
    assert not hasattr(r, "_reversed")
    r.reversed
    assert hasattr(r, "_reversed")
    r.remap({1: "foo"})
    assert not hasattr(r, "_reversed")
    r.reversed
    assert hasattr(r, "_reversed")
    r.unmap()
    assert not hasattr(r, "_reversed")
    assert r.reversed == {2: 1}
    assert hasattr(r, "_reversed")
Ejemplo n.º 4
0
def test_rrd_remapping_sets_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r.original == {1: 2}
    assert hasattr(r, "_original")
Ejemplo n.º 5
0
def test_rrd_remapping_deletes_reversed():
    r = RRD({1: 2})
    r.reversed
    assert hasattr(r, "_reversed")
    r.remap({1: "foo"})
    assert not hasattr(r, "_reversed")
Ejemplo n.º 6
0
def test_rrd_remapping():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r["foo"] == 2
Ejemplo n.º 7
0
def test_rrd_remapping_multiple():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    r.remap({"foo": "bar"})
    assert r["bar"] == 2
Ejemplo n.º 8
0
def test_rrd_remapping_multiple_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    r.remap({"foo": "bar"})
    assert r.original == {"foo": 2}