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__removals__returns_no_items__when_added_item_is_added_and_removed(): d = IdMapper() d["a"] = 1 del d["a"] assert [(k, v) for k, v in d.removals()] == [] assert [(k, v) for k, v in d.additions()] == []
def test__additions__return_items_added__when_changed_multiple_times(): d = IdMapper() d["a"] = 1 d["a"] = 2 d["a"] = 3 assert [(k, v) for k, v in d.additions()] == [("a", 3)]
def test__additions__return_items_added__when_added_using_reverse_map(): d = IdMapper() d.reverse[1] = "a" assert [(k, v) for k, v in d.additions()] == [("a", 1)]
def test__additions__return_items_added(): d = IdMapper() d["a"] = 1 assert [(k, v) for k, v in d.additions()] == [("a", 1)]