2020-06-20 14:53:44 +02:00
|
|
|
import pytest
|
2020-01-25 14:20:25 +01:00
|
|
|
|
|
|
|
import util.store
|
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def emptyStore():
|
|
|
|
return util.store.Store()
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def store():
|
|
|
|
return util.store.Store()
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_of_unset_key(emptyStore):
|
|
|
|
assert emptyStore.get("any-key") == None
|
|
|
|
assert emptyStore.get("any-key", "default-value") == "default-value"
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_of_set_key(store):
|
|
|
|
store.set("key", "value")
|
|
|
|
assert store.get("key") == "value"
|
|
|
|
|
|
|
|
|
|
|
|
def test_overwrite_set(store):
|
|
|
|
store.set("key", "value 1")
|
|
|
|
store.set("key", "value 2")
|
|
|
|
|
|
|
|
assert store.get("key") == "value 2"
|
|
|
|
|
|
|
|
|
|
|
|
def test_unused_keys(store):
|
|
|
|
store.set("key 1", "value x")
|
|
|
|
store.set("key 2", "value y")
|
|
|
|
|
|
|
|
assert store.unused_keys() == sorted(["key 1", "key 2"])
|
|
|
|
|
|
|
|
store.get("key 2")
|
|
|
|
|
|
|
|
assert store.unused_keys() == ["key 1"]
|
|
|
|
|
|
|
|
store.get("key 1")
|
|
|
|
|
|
|
|
assert store.unused_keys() == []
|
2020-01-25 14:20:25 +01:00
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-01-25 14:20:25 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|