def test__removals_nor_changes__returns_no_items__when_item_is_put_back(): d = IdMapper({"a": 1}) del d["a"] d["a"] = 1 assert [(k, v) for k, v in d.removals()] == [] assert [(k, v) for k, v in d.additions()] == [] assert [(k, v) for k, v in d.changes()] == []
def test__changes__returns_item__when_it_is_first_deleted_and_then_changed(): d = IdMapper({"a": 1}) del d["a"] d["a"] = 2 assert [(k, v) for k, v in d.removals()] == [] assert [(k, v) for k, v in d.additions()] == [] assert [(k, v) for k, v in d.changes()] == [("a", 2)]
def test__changes__returns_changed_items__when_changed_using_reverse_map(): d = IdMapper({"b": 2}) d.reverse[3] = "b" assert [(k, v) for k, v in d.changes()] == [("b", 3)]
def test__changes__returns_none__when_value_has_not_changed(): d = IdMapper({"b": 2}) d["b"] = 2 assert [(k, v) for k, v in d.changes()] == []
def test__changes__returns_changed_items(): d = IdMapper({"b": 2}) d["b"] = 3 assert [(k, v) for k, v in d.changes()] == [("b", 3)]