def test_delitem(): dad = item_state._DynamicValueStore() dad[_TEST_KEY] = None assert _TEST_KEY in dad # setup del dad[_TEST_KEY] assert _TEST_KEY not in dad
def test_popitem(): dad = item_state._DynamicValueStore() dad[_TEST_KEY] = None assert _TEST_KEY in dad # setup dad.pop(_TEST_KEY) assert _TEST_KEY not in dad
def test_removed_del(): dad = item_state._DynamicValueStore() try: del dad[_TEST_KEY] except KeyError: pass assert dad.removed_keys == {_TEST_KEY}
def test_setitem(): dad = item_state._DynamicValueStore() value = object() dad[_TEST_KEY] = value assert dad[_TEST_KEY] is value assert not dad.removed_keys # remove and re-add (no, this is not trivial!) dad.pop(_TEST_KEY) dad[_TEST_KEY] = value assert not dad.removed_keys
def _get_store() -> item_state._EffectiveValueStore: dynstore = item_state._DynamicValueStore() dynstore.update({ ("dyn", "key", "1"): "dyn-val-1", ("dyn", "key", "2"): "dyn-val-2", }) return item_state._EffectiveValueStore( dynamic=dynstore, static= { # type: ignore[arg-type] ("stat", "key", "1"): "stat-val-1", ("stat", "key", "2"): "stat-val-2", }, )
def test_removed_pop(): dad = item_state._DynamicValueStore() dad.pop(_TEST_KEY, None) assert dad.removed_keys == {_TEST_KEY}
def test_init(): dad = item_state._DynamicValueStore() assert not dad assert not dad.removed_keys