Example #1
0
    def test_delitem():
        dad = _DynamicValueStore()
        dad[_TEST_KEY] = None
        assert _TEST_KEY in dad  # setup

        del dad[_TEST_KEY]
        assert _TEST_KEY not in dad
Example #2
0
    def test_popitem():
        dad = _DynamicValueStore()
        dad[_TEST_KEY] = None
        assert _TEST_KEY in dad  # setup

        dad.pop(_TEST_KEY)
        assert _TEST_KEY not in dad
Example #3
0
 def test_removed_del():
     dad = _DynamicValueStore()
     try:
         del dad[_TEST_KEY]
     except KeyError:
         pass
     assert dad.removed_keys == {_TEST_KEY}
Example #4
0
    def test_setitem():
        dad = _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
Example #5
0
 def _get_store() -> _EffectiveValueStore:
     dynstore = _DynamicValueStore()
     dynstore.update({
         ("dyn", "key", "1"): "dyn-val-1",
         ("dyn", "key", "2"): "dyn-val-2",
     })
     return _EffectiveValueStore(
         dynamic=dynstore,
         static=
         {  # type: ignore[arg-type]
             ("stat", "key", "1"): "stat-val-1",
             ("stat", "key", "2"): "stat-val-2",
         },
     )
Example #6
0
 def test_removed_pop():
     dad = _DynamicValueStore()
     dad.pop(_TEST_KEY, None)
     assert dad.removed_keys == {_TEST_KEY}
Example #7
0
 def test_init():
     dad = _DynamicValueStore()
     assert not dad
     assert not dad.removed_keys